menu

PHP Syntax


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

function function_name()

function_name()

function function_name(parameters)

function function_name(parameters)


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 loop through the values of an array in PHP?

for loop

while loop

foreach loop

do-while loop


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 check if a variable is null in PHP?

is_null($variable)

$variable == null

$variable === null

all of the above


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


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

exit

continue

break

return


9. 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;


10. Which of the following is used to define a namespace in PHP?

namespace Namespace_name;

use Namespace_name;

define Namespace_name;

all of the above