Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

1.

Key/value pair in associative array can be initialized using = operator


Select one:
True
False

2. In a 3-tier web architecture, which tier is responsible for rendering a web page

a.
server

b.
client

c.
database

d.
none of the above

3. The output for this code is


$str="We Studied PHP";
echo strlen(substr($str,3,2));

a.
1

b.
2

c.
3

d.
Array
4. The output of this code is:
$email = "student1@iugaza.edu.ps";
echo ltrim(strstr($email, "@"),"@");

a.
student1

b.
iugaza.edu.ps

c.
student1@iugaza.edu.ps

d.
student1@

5. Which statement will get $num on the screen

a.
echo “\$num”;

b.
echo “$$num”;

c.
echo “/$num”;

d.
echo “$num;”;
6. The break statement ends execution of which of the following

a.
while

b.
for

c.
switch

d.
all of the above

7. In PHP, $myvar and $myVar are the same variable


Select one:
True
False

8. PHP is uninterpreted language


Select one:
True
False

9. Variable can be

a.
long descriptive names

b.
short names

c.
a,b

d.
None of the above
10. What is the function that searches for a specific text in a string

a.
strpos()

b.
strposition()

c.
strrev()

d.
str_replace()

11. PHP is a programming language used for building static Web sites.
Select one:
True
False

12. Which statement will store 111 in variable x?

a.
int $x=111;

b.
int x=111;

c.
$x = 111;

d.
111=$x;

13. In array, Keys can be non-sequential


Select one:
True
False
14. Which is the incorrect variable name in PHP

a.
$_UserName

b.
$18Username

c.
$Username18

d.
$_Username18
15. What the output of this PHP code
$city = "Jerusalem";
$var = $city[2];
echo '$var ';

a.
r

b.
e

c.
error

d.
$var
16. The output of this code is
$Englishalphabet = array ("a", "t", "x");
echo (next($Englishalphabet));

a.
t

b.
x

c.
a

d.
Error

17. What the output of the following PHP code


$operation = "edit";
switch ($operation) {
case "save":
echo "Save File";
case "edit":
echo "Edit File ";
case "delete":
echo "Delete File "; }

a.
Edit File

b.
Error

c.
Edit File Delete File

d.
Edit File Delete File Save File
18. What is the output for this code?
$nums=array(20,100,350,543,600);
next($nums);
next($nums);
next($nums);
echo current($nums);

a.
600

b.
543

c.
350

d.
Error

19. Array values are keyed by ______ values (called indexed arrays) or using
______ values (called associative arrays).

a.
float, string

b.
even number, string

c.
string, boolean

d.
integer, string
20. Indexed array by default start from

a.
1

b.
0

c.
-1

d.
2

21. Which of the statements is equivalent to $x += $x

a.
$x = $x

b.
$x = $x+ $x

c.
$x = $x+1

d.
$x = $x+ $x+1
22. What will be the output of the following PHP code
$userAge = array(20, 50, 34, 42);
for($x=0;$x<count($userAge);$x++)
{
if ($userAge [$x] == 50) continue;
echo $userAge[$x];
}

a.
20

b.
203442

c.
3442

d.
50

23. Which one of these functions aren’t a Built-in String functions in PHP

a.
strlen()

b.
str_replace()

c.
strpos()

d.
strreverse()
24. Which function can add value to the end of array

a.
array_unshift()

b.
array_pop()

c.
array_push()

d.
array_shift()

25. We use trim() function to

a.
remove whitespaces

b.
remove lowercase alphabet

c.
remove uppercase alphabet

d.
remove underscore

26. Echo statement has a return value


Select one:
True
False
27. We use is_array() function to

a.
print the array in readable format.

b.
add elements to the beginning of the array and returns the size of array.

c.
verify if a variable is an array and returns TRUE or FALSE

d.
add elements to the end of the array and returns the size of array.

28. function is used to sort an array in ascending order by value while preserving
key associations.

a.
ksort()

b.
asort()

c.
krsort()

d.
usort()
29. In PHP: $myvar =
“2”.“5”;

$myvar will most likely be:

a.
Integer 7

b.
Integer 25

c.
String 25

d.
Integer (ascii value of character 2 times ascii value of character 5)

30. If $mark = 40 what will be returned when ($mark >= 40) ? "Pass" : "Fail" is
executed?

a.
40

b.
Fail

c.
Error

d.
Pass
31. What the output of this PHP code
print("Islamic"."University"."of"."Gaza");

a.
IslamicUniversityofGaza

b.
Islamic University of Gaza

c.
Nothing

d.
Error

32. PHP stands for

a.
Personal Home Page

b.
Hypertext Preprocessor

c.
Pretext Hypertext Processor

d.
Preprocessor Home Page
33. What the output of the following PHP code
$a = 1;
$b = 2;
$c = 3;
echo ($a % ($b) + $c);

a.
2

b.
3

c.
4

d.
5

34. Which type of quotes can processes special characters inside

a.
single quotes

b.
double quotes

c.
both a and b

d.
None of the above
35. What the output of
var_dump(strpos("Web Development -2- course", "course"));

a.
int(18)

b.
char(20)

c.
int(20)

d.
char(18)

You might also like