menu

Web Development With PHP


1. Which PHP function is used to encode data in JSON format?

json_encode()

encode_json()

json()

json_format()


2. Which of the following is NOT a valid way to access an element in an array in PHP?

$array[0]

$array{"key"}

$array["key"]

$array->key


3. Which PHP function is used to convert a string to all uppercase letters?

strtoupper()

upper()

toUpper()

caseUpper()


4. Which of the following is NOT a web development language?

PHP

HTML

CSS

Java


5. Which of the following is NOT a valid way to declare a variable in PHP?

$variable = "value";

var $variable = "value";

$variable = array("value1", "value2");

$variable = 123;


6. Which of the following is NOT a valid way to declare a variable in PHP?

$variable = "value";

var $variable = "value";

$variable = array("value1", "value2");

$variable = 123;


7. Which PHP function is used to remove whitespace from the beginning and end of a string?

trim()

rtrim()

ltrim()

strip()


8. Which PHP function is used to get the current date and time?

time()

date()

datetime()

now()


9. Which PHP function is used to retrieve the length of a string?

length()

size()

strlen()

count()


10. Which of the following is NOT a valid loop in PHP?

for

while

do-while

repeat-until