menu

PHP Basics


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

$_COOKIE[]

$_SESSION[]

$_REQUEST[]

$_GET[]


2. Which of the following is used to comment out a single line in PHP?

//

#

/*

//


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

rand()

random()

random_number()

generate_random_number()


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

try-catch blocks

if-else statements

switch statements

none of the above


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 remove the last element from 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 resource in PHP?

is_resource()

resource()

isResource()

none of the above


8. Which of the following is used to replace a part of a string with another string in PHP?

str_replace()

str_swap()

replace_str()

none of the above


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

is_string()

string()

isString()

none of the above


10. Which of the following is used to replace a substring in a string in PHP?

str_replace()

replace()

substr_replace()

replace_substr()