menu

PHP Syntax


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

function_name();

call function_name();

function call(function_name);

call(function_name);


2. Which of the following is used to create an object of a class in PHP?

Class_name = new Class();

new Object = Class_name();

new Class_name();

Object = new Class_name;


3. Which of the following is used to call a method of an object in PHP?

object_name.method_name();

call object_name.method_name();

object_name(call method_name());

object_name->method_name();


4. 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


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

function function_name()

function_name()

function function_name(parameters)

function function_name(parameters)


6. Which of the following is used to check if a variable is set in PHP?

isset($variable)

$variable is set

$variable set

all of the above


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

exit

continue

break

return


8. Which of the following is used to execute a block of code at least once and repeatedly as long as a condition is true in PHP?

if statement

switch statement

for loop

do-while loop


9. Which of the following is used to execute a block of code only if a condition is true in PHP?

if statement

switch statement

for loop

while loop


10. Which of the following is used to compare two values for equality in PHP?

==

=

===

!=