My Report (&Account)

PHP Online Test


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)

Here is the complete list of test quizzes on PHP.

1. What will be the output of the following PHP code?

<?php
$a = 12;
--$a;
echo $a++;
?>

Question 1 of 50 (sanfoundry.com)

2. How many functions does PHP offer for searching strings using POSIX style regular expression?

Question 2 of 50 (sanfoundry.com)

3. Which logging option's description is if an error occurs when writing to the syslog, send output to the system console?

Question 3 of 50 (sanfoundry.com)

4. What will be the output of the following code? (If say date is 22/06/2013.)

    <?php
    echo "Today is ".date("F d, Y");
    ?>

Question 4 of 50 (sanfoundry.com)

5. What is the return type of session_set_save_handler() function?

Question 5 of 50 (sanfoundry.com)

6. UML stands for?

Question 6 of 50 (sanfoundry.com)

7. What will be the output of the following PHP code?

<?php
$x;
echo "$x";
?>

Question 7 of 50 (sanfoundry.com)

8. What will be the output of the following PHP code?

<?php
for ($i = 0; $i < 3; $i++)
{
    for($j = $i; $j > 0; $j--)
        print " ";
    for($k = $j; $k < 3; $k++)
        print "*";
	print "\n";  
}
?>

Question 8 of 50 (sanfoundry.com)

9. What will be the output of the following PHP code?

<?php
echo "This is <i>India</i>";
?>

Question 9 of 50 (sanfoundry.com)

10. Which variable is used to collect form data sent with both the GET and POST methods?

Question 10 of 50 (sanfoundry.com)

11. What will be the output of the following PHP code?

<?php
$a = 10;
echo ++$a;
echo $a++;
echo $a;
echo ++$a;
?>

Question 11 of 50 (sanfoundry.com)

12. What will be the output of the following PHP code?

<?php 
$x = 75;
$y = 25; 
function addition()
{
    $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
}
addition();
echo $z;
?>

Question 12 of 50 (sanfoundry.com)

13. What will be the output of the following PHP code?

    <?php
    $num  = "1";
    $num1 = "2";
    print $num+$num1;
    ?>
    

Question 13 of 50 (sanfoundry.com)

14. How many of the following can be contained in constants?

i) boolean
ii) integer
iii) float
iv)  string

Question 14 of 50 (sanfoundry.com)

15. What will be the output of the following PHP code?

<?php
$x = 4;
$y = 3;
function fun($x = 3, $y = 4)
{
    $z = $x+$y/$y+$x;
    echo "$z";
} 
echo $x;
echo $y;
echo $z; 
fun($x, $y);
?>

Question 15 of 50 (sanfoundry.com)

16. What will be the output of the following PHP code?

    
<?php
    echo stripos("I love php, I love php too!","PHP");
?>

Question 16 of 50 (sanfoundry.com)

17. What will be the output of the following PHP code?

<?php
$y = 2;
$w = 4;
$y *= $w /= $y;
echo $y, $w;
?>

Question 17 of 50 (sanfoundry.com)

18. What will be the output of the following PHP code?

    <?php
    $states = array("Karnataka" => array
    ("population" => "11,35,000", "capital" => "Bangalore"),
    "Tamil Nadu" => array( "population" => "17,90,000",
    "capital" => "Chennai") );
    echo $states["Karnataka"]["population"];
    ?>

Question 18 of 50 (sanfoundry.com)

19. The class from which the child class inherits is called ________

i) Child class
ii) Parent class
iii) Super class
iv) Base class

Question 19 of 50 (sanfoundry.com)

20. What will be the output of the following PHP code?

    <?php
    $line = "You like dogs. I hate dogs. We should marry.";
    $sen = preg_split('/\./', $line);
    print_r($sen);
    ?>
    

Question 20 of 50 (sanfoundry.com)

21. Which function is used to erase all session variables stored in the current session?

Question 21 of 50 (sanfoundry.com)

22. If the diamond is filled it depicts which relationship?

Question 22 of 50 (sanfoundry.com)

23. POSIX implementation was deprecated in which version of PHP?

Question 23 of 50 (sanfoundry.com)

24. Type Hinting was introduced in which version of PHP?

Question 24 of 50 (sanfoundry.com)

25. What will be the output of the following PHP code?

<?php
$a = 2;
if ($a-- - --$a - $a)
    print "hello";
else
    print "hi";
?>

Question 25 of 50 (sanfoundry.com)

26. Prior to which version of PHP did constructors took the name of the enclosing class.

Question 26 of 50 (sanfoundry.com)

27. Which version added the method getPrevious()?

Question 27 of 50 (sanfoundry.com)

28. Which one of the following statements should be used to include a file?

Question 28 of 50 (sanfoundry.com)

29. What will be the output of the following PHP code?

<?php
function start($string)
{
    if ($string < 45)
        return 20;
    else
        return 40;
}
$t = start(90);
if ($t < 20)
{
    echo "Have a good day!";
}
else
{
    echo "Have a good night!";
}
?>

Question 29 of 50 (sanfoundry.com)

30. What will be the output of the following PHP code?

<?php
$a  =  '12345';
echo "qwe$arty";
?>

Question 30 of 50 (sanfoundry.com)

31. Which function effectively deletes all sessions that have expired?

Question 31 of 50 (sanfoundry.com)

32. Which version of PHP introduced Try/catch Exception?

Question 32 of 50 (sanfoundry.com)

33. Output:

    namespace main;
    com\getinstance\util\Debug::helloWorld()
PHP Fatal error: Class 'main\com\getinstance\util\Debug' not found in ...

Using which one of the following PHP lines will the error be removed?

Question 33 of 50 (sanfoundry.com)

34. What will be the output of the following PHP code?

<?php
$i = 0
while ($i < 3)
{
    $i++;
}
print $i;
?>

Question 34 of 50 (sanfoundry.com)

35. Which of the following is/are true for an abstract class?
i) Abstract classes in PHP are declared with the help of abstract keyword.
ii) A class is declared abstract by using the keyword implements.
iii) It is a class that really isn’t supposed to ever be instantiated but instead serves as a base class.
iv) Attempting to instantiate an abstract class results in an error.

Question 35 of 50 (sanfoundry.com)

36. What will be the output of the following PHP code?

<?php
$i = 0;
for ($i)
{
    print $i;
}
?>

Question 36 of 50 (sanfoundry.com)

37. The developers of PHP deprecated the safe mode feature as of which PHP version.

Question 37 of 50 (sanfoundry.com)

38. What will be the output of the following PHP code?

<?php
$a = "2";
switch ($a)
{
case 1:
    print "hi";
case 2:
    print "hello";
    break;
default:
    print "hi1";
}
?>

Question 38 of 50 (sanfoundry.com)

39. What will be the output of the following PHP code?

<?php
$var1 = 0;
$var1 = $var1++ + 5; 
echo $var1; 
?>

Question 39 of 50 (sanfoundry.com)

40. Which version introduced the function error_get_last()?

Question 40 of 50 (sanfoundry.com)

41. What will be the output of the following PHP code?

<?php
$a = 2;
if ($a-- - --$a - $a)
    print "hello";
else
    print "hi";
?>

Question 41 of 50 (sanfoundry.com)

42. At least how many abstract methods must an abstract class contain?

Question 42 of 50 (sanfoundry.com)

43. To process the file, you need to break the array from $_FILES into individual values. You can do this using the ________ function.

Question 43 of 50 (sanfoundry.com)

44. What will be the output of the following PHP code?

<?php
$number = range(0, 5);
print_r ($number);
?>

Question 44 of 50 (sanfoundry.com)

45. How many constants does the DateTime class have?

Question 45 of 50 (sanfoundry.com)

46. What will be the output of the following PHP code?

<?php
echo $red;
?>

Question 46 of 50 (sanfoundry.com)

47. What will be the output of the following PHP code?

<?php
$a = "$winner";
$b = "\\$looser";
echo $a, $b;
?>

Question 47 of 50 (sanfoundry.com)

48. What will be the value of $a and $b after the function call in the following PHP code?

    <?php
    function doSomething( &$arg ) {
        $return = $arg;
        $arg += 1;
        return $return;	
    }
    $a = 3;
    $b = doSomething( $a );
    ?>
        

Question 48 of 50 (sanfoundry.com)

49. Which one of the following method is used to retrieve the number of rows affected by an INSERT, UPDATE, or DELETE query?

Question 49 of 50 (sanfoundry.com)

50. What will be the output of the following PHP code?

<?php
$user = array("Ashley", "Bale", "Shrek", "Blank");
for ($x = 0; $x < count($user); $x) 
{
    if ($user[$x++] == "Shrek") 
	    continue;
    printf ($user[$x]); 
}
?>

Question 50 of 50 (sanfoundry.com)


 

Topic wise Test Quizzes on PHP

PHP tests, quizzes, and exams are great ways to learn and test your PHP programming skills. Whether you’re a beginner or experienced, challenge and boost your confidence with our engaging online quizzes on PHP Basics, Array, Loops, OOP, String, Database, Object, if else Statement, Operators, Function, and Advanced PHP. Start the PHP online test now!



PHP Programming Certification Test

PHP Programming Certification Test is a free certification exam. However, you need to score an A grade in each of the "Certification Level Tests 1 to 10" to be eligible to take part in this certification test. So, take all the "10 Tests" starting from Certification Level 1 upto Level 10, before taking the final Certification test.


Level 1 to 10 Tests:
Total Questions: 25, Total Time: 30 min, Correct Answer: 2 points, Wrong Answer: -1 point

Certification Test:
Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

PHP Programming Internship Test

If you scored either Grade A* or Grade A in our PHP Programming Internship Test, then you can apply for Internship at Sanfoundry in PHP Programming.


Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

PHP Programming Job Test

It is designed to test and improve your skills for a successful career, as well as to apply for jobs.


Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

Note: Before you get started on these series of online tests, you should practice our collection of 1000 MCQs on PHP Programming .

Sanfoundry Scoring & Grading System

Sanfoundry tests and quizzes are designed to provide a real-time online exam experience. Here is what you need to know about them.

  • Scoring System: You get 2 points for each correct answer but lose 1 point for every wrong answer.
  • Grading System: Your grade depends on your final score and can be one of the following:

    • Grade A* - Genius (100%)
    • Grade A - Excellent (80% to 99%)
    • Grade B - Good (60% to 80%)
    • Grade C - Average (40% to 60%)
    • Grade D - Poor (0% to 40%)
advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 20s–40s and exploring new directions in your career, I also offer mentoring. Learn more here.