PHP Sample Test Quiz
1. What do PHP stand for?
Personal Hypertext Preprocessor Pretext Hypertext Processor Hypertext Processor None2. A PHP code should put butween?
<php> and </php> <?php and ?> <? and ?> <?php and php?>3. Which version of PHP introduced Try/catch Exception?
PHP 5 PHP 6 PHP 7 PHP 44. What extension is used for PHP code file?
.html .ht .php .ph5. Which of the statement will store value 111 in a PHP variable name num?
int $num = 111; int num = 111; integer num = 111; $num = 111;6. How to create a function in PHP?
function test() function=test() function:test() function::test()7. How to call a function named "test" in PHP?
function test() call test() test() call function test()8. How to comment/comment code in PHP?
//my comment 'my comment <--my comment--> /my comment/9. How to declare a variable in PHP?
$myvar; var $myvar; var myvar; variable $myvar;10. Which attribute is used to use a global variable in PHP?
scope glob global None11. Which one is used to new line in PHP?
\n /n \r /r12. A function in PHP which starts with double underscore is known as?
Inbuilt funcion Magic function User defined function Default function13. Which version of PHP introduced Type hinting?
PHP 4 PHP 5 PHP 6 PHP 714. Which is the valid function name in PHP?
$function() .function() #() function()15. Which of the following is not a valid PHP variable name?
_varname 2varname varname None16. Which language is used to server side validation of a web page?
PHP HTML CSS XML17. How to write for loop in PHP?
for($i=0; $i<=10; ++$i) for i=10 then iterate for each (i<=10) for(i=0; i<=10; ++i)18. Which of the following is correct way to write "Hello World" on the screen?
echo("Hello World"); print("Hello World"); out.print("Hello World"); document.write("Hello World");19. Which will print $x on the screen?
echo "$x"; echo "\$x"; echo "$$x"; echo "/$x";20. Which statement is equivalent to $x += $x ?
$x = $x; $x = $x + $x + 1; $x = $x + $x; $x = $x + 1;