PHP is a server side scripting language that allows quick development of dynamic web application. PHP code can be embedded into HTML source document which later interpreted by PHP module to generate web pages.

PHP Quiz

Attempts allowed:Unlimited
Pass rate:75 %
Backwards navigation:Allowed

This PHP quiz contains questions for PHP developers to test their knowledge in the PHP language.
This is a free online PHP quiz.
PHP language is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

Start quiz

return function is omitted

Multiple choice question

If a return statement is omitted from a function, what value will be returned as the function terminates?

Explode function in PHP

Multiple choice question

Which of the following functions, gets a separator string and a target string as arguments and returns an array of strings?

ArrayObject as a parameter to "is_array" function

True/false question

What is the return value of ‘is_array’ function which gets ArrayObject as parameter?

Current class instance in PHP

Multiple choice question

Which keyword is used to refer to the current instance of a class?

escaping user generated values

Multiple choice question

It is known that any user generated string value needs to be escaped before using it and especially in a MySQL queries (to prevent SQL injection).
Is it a problem to use un-escaped database retrieved value in a new query to the database?

Null as parameter to ‘isset’ function

Multiple choice question

Given the following PHP code, what will be the output?


if (isset($t))
echo "t is set";
echo "t is not set";

Null value in comparison expression

Multiple choice question

Given the following PHP code, what will be the output?

function print_weather($weather){
if ($weather =="hot")
$weather_id = 0;
else if ($weather =="cold")
$weather_id = 1;

if ($weather_id == null)
echo "Nice weather; ";
echo "Extreme weather; ";

Return an Array from PHP Function

Multiple choice question

How can a function return an array in PHP?

PHP array of arrays

Multiple choice question

PHP arrays are a useful way to handle series of variables. An array can hold another array.
What will be the output of the following code?

$tops = array(
0=>array("user_id"=>34, "user_name"=>"Dan"),
1=>array("user_id"=>35, "user_name"=>"Ben"),
2=>array("user_id"=>36, "user_name"=>"Roy"));

foreach ($tops as $key=>$top){
$top["user_id"] = $key;
echo " {$tops[0]["user_id"]} ";

Syndicate content