menu

PHP Syntax


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


2. What is the correct syntax to pass arguments to a function in PHP?

function_name(arguments)

function_name(arguments;)

function_name(arguments,)

function_name(arguments);


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

include "filename";

require "filename";

include_once "filename";

all of the above


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

exit

continue

break

return


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

define('Constant_name', 'value');

constant Constant_name = value;

Constant_name = value;

all of the above


6. 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();


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

setcookie('cookie_name', 'cookie_value');

cookie('cookie_name', 'cookie_value');

create_cookie('cookie_name', 'cookie_value');

all of the above


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


9. Which of the following is used to access a property of an object in PHP?

object_name->property_name;

object_name.property_name;

object_name[property_name];

object_name->(property_name);


10. What is the correct syntax to declare a variable in PHP?

$variable_name;

var variable_name;

$variable_name =;

variable_name;