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 define a constant in PHP?

define('Constant_name', 'value');

constant Constant_name = value;

Constant_name = value;

all of the above


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

$variable_name;

var variable_name;

$variable_name =;

variable_name;


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

include "filename";

require "filename";

include_once "filename";

all of the above


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 concatenate two strings in PHP?

.

+

-

*


7. Which of the following is used to execute a block of code repeatedly as long as a condition is true in PHP?

if statement

switch statement

for loop

while loop


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


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