wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

appdev_PHP

Total questions: 92

Worksheet time: 2hrs 32mins

Name
Class
Date
1.
A multidimensional array is an array containing one or more arrays.
a)
True
b)
False
2.
A valid PHP variable name can start with a number.
a)
True
b)
False
3.
An associative array uses named keys that you assign to them.
a)
True
b)
False
4.
Comments in PHP can be written using the # symbol.
a)
True
b)
False
5.
Functions in PHP are case-sensitive.
a)
True
b)
False
6.
In PHP, the keys of an associative array must be integers.
a)
True
b)
False
7.
In a "foreach" loop, the `as` keyword is used to assign the current element's value to a variable.
a)
True
b)
False
8.
In a multidimensional array, you use multiple indices to access elements (e.g., `$arr[0][1]`).
a)
True
b)
False
9.
In a switch statement, if a matching case does not contain a "break" statement, execution continues to the next case.
a)
True
b)
False
10.
PHP stands for "Personal Home Page".
a)
True
b)
False
11.
PHP variable names are case-sensitive.
a)
True
b)
False
12.
PHP variables declared within a function are local and cannot be accessed outside of that function.
a)
True
b)
False
13.
Single-quoted strings in PHP (' ') will parse variables inside them (e.g., 'Hello $name').
a)
True
b)
False
14.
Static variables inside a function lose their value after the function execution is completed.
a)
True
b)
False
15.
The "break" statement is used to jump out of a switch statement or a loop.
a)
True
b)
False
16.
The "continue" statement breaks the loop and stops execution completely.
a)
True
b)
False
17.
The $_GET superglobal variable sends form data appended to the URL, making it visible to everyone.
a)
True
b)
False
18.
The $_REQUEST superglobal variable contains the contents of both $_GET, $_POST, and $_COOKIE.
a)
True
b)
False
19.
The === operator checks for equality in both value and data type.
a)
True
b)
False
20.
The `$_SERVER['PHP_SELF']` variable returns the filename of the currently executing script.
a)
True
b)
False
21.
The `break` statement accepts an optional numeric argument to specifying how many nested structures to break out of.
a)
True
b)
False
22.
The `do...while` loop checks the condition before executing the block of code.
a)
True
b)
False
23.
The `empty()` function returns TRUE for the string "0".
a)
True
b)
False
24.
The `filter_var()` function can be used to validate if a string is a valid email address using `FILTER_VALIDATE_EMAIL`.
a)
True
b)
False
25.
The `implode()` function splits a string into an array.
a)
True
b)
False
26.
The `include` statement generates a fatal error and stops the script if the file cannot be found.
a)
True
b)
False
27.
The `print_r()` function is used to display information about a variable in a way that is readable by humans.
a)
True
b)
False
28.
The `require_once` statement is identical to `require` except PHP will check if the file has already been included, and if so, not include it again.
a)
True
b)
False
29.
The do...while loop guarantees that the code block is executed at least once.
a)
True
b)
False
30.
The empty() function returns TRUE if a variable exists and is not NULL.
a)
True
b)
False
31.
The foreach loop is specifically designed to iterate over arrays.
a)
True
b)
False
32.
The is_numeric() function checks if a variable is a number or a numeric string.
a)
True
b)
False
33.
The sort() function sorts an array in descending order.
a)
True
b)
False
34.
Variables declared inside a function are destroyed when the function exits.
a)
True
b)
False
35.
What is the output of the code below? $a = 0; echo isset($a);
a)
1 (or True)
b)
0
c)
False
d)
NULL
36.
What is the output of the code below? $age = array("Peter"=>"35", "Ben"=>"37"); echo $age['Ben'];
a)
35
b)
37
c)
Ben
d)
Peter
37.
What is the output of the code below? $arr = ["A", "B", "C"]; echo $arr[1];
a)
A
b)
B
c)
C
d)
NULL
38.
What is the output of the code below? $arr = ["A", "B"]; echo implode("-", $arr);
a)
A-B
b)
AB
c)
Array
d)
A, B
39.
What is the output of the code below? $arr = ["a" => 1, "b" => 2]; echo array_key_exists("a", $arr);
a)
1 (or True)
b)
0
c)
False
d)
a
40.
What is the output of the code below? $cars = array("Volvo", "BMW", "Toyota"); echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
a)
I like Volvo, BMW and Toyota.
b)
I like Volvo, BMW, and Toyota.
c)
I like Volvo, BMW and Toyota
d)
Error
41.
What is the output of the code below? $colors = ["Red", "Blue"]; echo $colors[2];
a)
Blue
b)
Error or Undefined
c)
Red
d)
NULL
42.
What is the output of the code below? $colors = ["Red", "Green"]; unset($colors[0]); echo $colors[0];
a)
Error (or Undefined)
b)
Red
c)
Green
d)
NULL
43.
What is the output of the code below? $colors = array("red", "green", "blue"); echo $colors[1];
a)
red
b)
green
c)
blue
d)
array
44.
What is the output of the code below? $txt = "Hello"; echo $txt[0];
a)
H
b)
e
c)
Hello
d)
Error
45.
What is the output of the code below? $val = null; echo $val ?? "Default";
a)
Default
b)
null
c)
0
d)
Empty
46.
What is the output of the code below? $x = "Hello"; $x .= " World"; echo $x;
a)
Hello World
b)
Hello
c)
World
d)
Error
47.
What is the output of the code below? $x = "Hello"; $y = "World"; echo "$x $y";
a)
Hello World
b)
$x $y
c)
HelloWorld
d)
Error
48.
What is the output of the code below? $x = 100; $y = "100"; var_dump($x == $y);
a)
bool(false)
b)
bool(true)
c)
100
d)
Error
49.
What is the output of the code below? $x = 10; echo $x++;
a)
11
b)
10
c)
Error
d)
NULL
50.
What is the output of the code below? $x = 10; echo ++$x;
a)
10
b)
11
c)
12
d)
Error
51.
What is the output of the code below? $x = 10; function myTest() { global $x; $x++; } myTest(); echo $x;
a)
11
b)
10
c)
0
d)
Error
52.
What is the output of the code below? $x = 5; $x += 10; echo $x;
a)
15
b)
510
c)
5
d)
10
53.
What is the output of the code below? $x = 5; function test() { $x = 10; } test(); echo $x;
a)
5
b)
10
c)
0
d)
Error
54.
What is the output of the code below? $x = true; $y = false; echo $x and $y;
a)
1 (or True)
b)
0
c)
False
d)
Error
55.
What is the output of the code below? $x = true; $y = false; var_dump($x && $y);
a)
bool(true)
b)
bool(false)
c)
1
d)
0
56.
What is the output of the code below? define("GREETING", "Welcome"); echo GREETING;
a)
Welcome
b)
GREETING
c)
$GREETING
d)
Error
57.
What is the output of the code below? echo "Hello" . " " . "World";
a)
Hello World
b)
Hello. .World
c)
HelloWorld
d)
Error
58.
What is the output of the code below? echo '5' + 10;
a)
15
b)
510
c)
5
d)
Error
59.
What is the output of the code below? echo (int) "100 apples";
a)
100
b)
0
c)
Error
d)
apples
60.
What is the output of the code below? echo (int) (10.9 + 10.9);
a)
21
b)
20
c)
22
d)
21.8
61.
What is the output of the code below? echo 10 . 20;
a)
30
b)
1020
c)
Error
d)
10.20
62.
What is the output of the code below? echo 10 / 4;
a)
2
b)
2.5
c)
3
d)
25
63.
What is the output of the code below? echo 10 <> 10;
a)
True
b)
False (or Empty)
c)
1
d)
Error
64.
What is the output of the code below? echo 2 ** 3;
a)
6
b)
8
c)
9
d)
5
65.
What is the output of the code below? echo 5 <=> 10;
a)
0
b)
1
c)
-1
d)
FALSE
66.
What is the output of the code below? echo 8 % 3;
a)
2
b)
1
c)
2.66
d)
0
67.
What is the output of the code below? echo abs(-50);
a)
50
b)
-50
c)
0
d)
Error
68.
What is the output of the code below? echo ceil(4.1);
a)
5
b)
4
c)
4.1
d)
0
69.
What is the output of the code below? echo count([1, 2, 3]);
a)
2
b)
3
c)
4
d)
0
70.
What is the output of the code below? echo count(null);
a)
0
b)
1
c)
NULL
d)
Error
71.
What is the output of the code below? echo floor(4.9);
a)
4
b)
5
c)
4.9
d)
0
72.
What is the output of the code below? echo is_int(10.5);
a)
False (or Empty)
b)
True
c)
1
d)
10
73.
What is the output of the code below? echo min(0, 150, 30, 20, -8, -200);
a)
0
b)
-200
c)
150
d)
-8
74.
What is the output of the code below? echo rand(1, 1);
a)
1
b)
0
c)
NULL
d)
Error
75.
What is the output of the code below? echo round(1.55, 1);
a)
1.6
b)
1.5
c)
2
d)
1
76.
What is the output of the code below? echo str_repeat("Yo", 3);
a)
YoYoYo
b)
Yo Yo Yo
c)
Yo3
d)
Error
77.
What is the output of the code below? echo str_replace("World", "PHP", "Hello World");
a)
Hello World
b)
Hello PHP
c)
PHP World
d)
World PHP
78.
What is the output of the code below? echo str_word_count("Hello world & good morning!");
a)
4
b)
5
c)
6
d)
2
79.
What is the output of the code below? echo str_word_count("Hello world!");
a)
12
b)
2
c)
10
d)
5
80.
What is the output of the code below? echo strcmp("Hello", "Hello");
a)
0
b)
1
c)
True
d)
False
81.
What is the output of the code below? echo strlen("Hello world!");
a)
12
b)
11
c)
2
d)
10
82.
What is the output of the code below? echo strpos("Hello World", "H");
a)
1
b)
0
c)
TRUE
d)
FALSE
83.
What is the output of the code below? echo strpos("Hello world!", "world");
a)
7
b)
6
c)
5
d)
False
84.
What is the output of the code below? echo strrev("PHP");
a)
HPP
b)
PHP
c)
php
d)
P H P
85.
What is the output of the code below? echo substr("ABCDEFG", 2, 3);
a)
CDE
b)
ABC
c)
BCD
d)
DEF
86.
What is the output of the code below? echo ucfirst("hello world");
a)
Hello world
b)
HELLO WORLD
c)
Hello World
d)
hello world
87.
What is the output of the code below? function msg($str="Hello") { echo $str; } msg();
a)
Hello
b)
Error
c)
NULL
d)
Empty
88.
What is the output of the code below? var_dump(10 == "10");
a)
bool(true)
b)
bool(false)
c)
10
d)
Error
89.
When defining a function, adding an ampersand (&) before a parameter name allows passing arguments by reference.
a)
True
b)
False
90.
When using the POST method, variables are displayed in the URL.
a)
True
b)
False
91.
Which function is used to convert special characters to HTML entities to prevent XSS attacks?
a)
htmlspecialchars()
b)
html_entity_decode()
c)
strip_tags()
d)
trim()
92.
Which superglobal variable is used to retrieve values stored in cookies?
a)
$_COOKIE
b)
$_SESSION
c)
$_GET
d)
$_SERVER