menu

PHP Syntax


1. What is the correct syntax to access an element in an array in PHP?

$array[element];

$array[element]

array[element];

array[element]


2. Which of the following is used to terminate a loop in PHP?

exit

continue

break

return


3. What is the correct syntax to include a file in PHP?

include "filename";

require "filename";

include_once "filename";

all of the above


4. What is the correct syntax to define a function in PHP?

function function_name()

function_name()

function function_name(parameters)

function function_name(parameters)


5. Which of the following is used to check if a variable is null in PHP?

is_null($variable)

$variable == null

$variable === null

all of the above


6. Which of the following is used to define a constant in PHP?

define()

const()

var()

let()


7. Which of the following is used to loop through the values of an array in PHP?

for loop

while loop

foreach loop

do-while loop


8. Which of the following is used to select one of several blocks of code to be executed in PHP?

if statement

switch statement

for loop

while loop


9. Which of the following is used to define a class in PHP?

define class Class_name {}

Class Class_name {}

new Class Class_name {}

class Class_name {}


10. Which of the following is used to call a function in PHP?

function_name();

call function_name();

function call(function_name);

call(function_name);