Home > PHP & Programming > Quizzes > PHP Programming Basics Practice Test: Basic Concepts Of PHP
PHP Programming Basics Practice Test: Basic Concepts Of PHP
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “Which statement will output $x on the screen?”
PHP, or Hypertext Preprocessor, is a general-purpose, open-source scripting language used for server-side web development. It's embedded into HTML codes, so a browser does not understand PHP. When someone visits a website, their browser requests the page from the server. The server checks for the .php file associated with the request, and if found, sends the file to the PHP interpreter. The PHP code then runs on the server, and generates an HTML page to send to the visitor. The visitor then sees the HTML page in their browser. It is called a preprocessor because it builds the information... Show more
PHP Programming Basics Practice Test: Basic Concepts Of PHP
Time left 00:00
25 Questions

1. Which of the following must be installed on your computer so as to run PHP script?
i) Adobe Dreamweaver
ii) XAMPP
iii) Apache and PHP
iv) IIS
2. What will be the output of the following PHP code?

function track() {
static $count = 0;
$count++;
echo $count;
}
track();
track();
track();
?>
3. Which statement will output $x on the screen?
4. Which is the right way of declaring a variable in PHP?
i) $3hello
ii) $_hello
iii) $this
iv) $This
5. Which of the looping statements is/are supported by PHP?
i) for loop
ii) while loop
iii) do-while loop
iv) foreach loop
6. What will be the value of $a and $b after the function call in the following PHP code?
function doSomething( &$arg ) {
$return = $arg;
$arg += 1;
return $return;
}
$a = 3;
$b = doSomething( $a );
?>
7. Which of the following PHP statement/statements will store 111 in variable num?
i) int $num = 111;
ii) int mum = 111;
iii) $num = 111;
iv) 111 = $num;
8. What will be the output of the following PHP code?

$total = "25 students";
$more = 10;
$total = $total + $more;
echo "$total";
?>
9. What will be the output of the following PHP code?

$foo = 'Bob';
$bar = &$foo;
$bar = "My name is $bar";
echo $bar;
echo $foo;
?>
10. What will be the output of the following PHP code?

$num = 1;
$num1 = 2;
print $num . "+". $num1;
?>
11. What will be the output of the following PHP code?

$score = 1234;
$scoreboard = (array) $score;
echo $scoreboard[0];
?>
12. What will be the output of the following PHP code?

$team = "arsenal";
switch ($team) {
case "manu":
echo "I love man u";
case "arsenal":
echo "I love arsenal";
case "manc":
echo "I love manc"; }
?>
13. Which of the below symbols is a newline character?
14. What will be the output of the following PHP code?

$num = "1";
$num1 = "2";
print $num+$num1;
?>
15. What will be the output of the following PHP code?

$color = "maroon";
$var = $color[2];
echo "$var";
?>
16. How should we add a single line comment in our PHP code?
i) /?
ii) //
iii) #
iv) /* */
17. What should be the correct syntax to write a PHP code?
18. Which of the following is/are a PHP code editor?
i) Notepad
ii) Notepad++
iii) Adobe Dreamweaver
iv) PDT"
19. What will be the output of the following PHP code?

$a = "clue";
$a .= "get";
echo "$a";
?>
20. If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?
21. Which version of PHP introduced Try/catch Exception?
22. What will be the output of the following PHP code?
$user = array("Ashley", "Bale", "Shrek", "Blank");
for ($x=0; $x < count($user); $x++){
if ($user[$x] == "Shrek") continue;
printf ($user[$x]);
}
?>
23. What will be the output of the following PHP code?

$a = 5;
$b = 5;
echo ($a === $b);
?>
24. Who is the father of PHP?
25. Which of the following PHP statements will output Hello World on the screen?
i) echo ("Hello World");
ii) print ("Hello World");
iii) printf ("Hello World");
iv) sprintf ("Hello World");