menu

PHP Basics


1. Which of the following is used to remove the last element from an array in PHP?

array_push()

array_pop()

array_shift()

array_unshift()


2. Which of the following is used to generate a random number in PHP?

rand()

random()

random_number()

generate_random_number()


3. Which of the following is used to handle errors in PHP?

try-catch blocks

if-else statements

switch statements

none of the above


4. Which of the following is used to read the value of a cookie in PHP?

$_COOKIE[]

$_SESSION[]

$_REQUEST[]

$_GET[]


5. Which of the following is used to get the length of a string in PHP?

strlen()

strlength()

length()

none of the above


6. Which of the following is used to add an element to the beginning of an array in PHP?

array_push()

array_pop()

array_shift()

array_unshift()


7. Which of the following is used to check if a variable is a string in PHP?

is_string()

string()

isString()

none of the above


8. Which of the following is used to set a cookie in PHP?

setcookie()

createcookie()

set_cookie()

create_cookie()


9. Which of the following is used to test if two values are equal in PHP?

==

=

===

!=


10. Which of the following is used to test if a variable is empty in PHP?

isset()

empty()

null()

unset()