Which of the following is correct about constants vs variables in php


This section presents you various set of Mock Tests related to PHP. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Which of the following is correct about constants vs variables in php

PHP Mock Test II

Answer : C

Explanation

Both of the above options are correct.

Answer : C

Explanation

Both of the above options are correct.

Answer : A

Explanation

_LINE_ − The current line number of the file.

Answer : B

Explanation

_FILE_ − The full path and filename of the file. If used inside an include,the name of the included file is returned. Since PHP 4.0.2, _FILE_ always contains an absolute path whereas in older versions it contained relative path under some circumstances.

Answer : C

Explanation

_FUNCTION_ − The function name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.

Answer : D

Explanation

_CLASS_ − The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.

Answer : A

Explanation

_METHOD_ − The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).

Q 8 - Which of the following keyword terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch?

A - break

B - continue

Answer : A

Explanation

break terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch.

Q 9 - Which of the following keyword causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating?

A - break

B - continue

Answer : B

Explanation

continue causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

Answer : A

Explanation

Numeric array − An array with a numeric index. Values are stored and accessed in linear fashion.

Answer : B

Explanation

Associative array − An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.

Answer : C

Explanation

Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices.

Answer : A

Explanation

To concatenate two string variables together, use the dot (.) operator.

Answer : B

Explanation

The strlen() function is used to find the length of a string.

Answer : C

Explanation

The strpos() function is used to search for a string or character within a string.

Answer : D

Explanation

PHP provides a function getenv() to access the value of all the environment variables.

Answer : A

Explanation

One of the environemnt variables set by PHP is HTTP_USER_AGENT which identifies the user's browser and operating system.

Answer : B

Explanation

The PHP rand() function is used to generate a random number. This function can generate numbers with-in a given range. The random number generator should be seeded to prevent a regular pattern of numbers being generated. This is achieved using the srand() function that specifiies the seed number as its argument.

Answer : A

Explanation

The PHP default variable $_PHP_SELF is used for the PHP script name and when you click "submit" button then same PHP script will be called.

Answer : A

Explanation

rsort() − Sorts an array in reverse order.

Answer : B

Explanation

The PHP header() function supplies raw HTTP headers to the browser and can be used to redirect it to another location. The redirection script should be at the very top of the page to prevent any other part of the page from loading.

Answer : A

Explanation

The PHP provides $_GET associative array to access all the sent information using GET method.

Answer : A

Explanation

The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.

Answer : A

Explanation

array() − Creates an array.

Answer : A

Explanation

array_reverse() − Returns an array in the reverse order.

Answer Sheet

Question NumberAnswer Key
1 C
2 C
3 A
4 B
5 C
6 D
7 A
8 A
9 B
10 A
11 B
12 C
13 A
14 B
15 C
16 D
17 A
18 B
19 A
20 A
21 B
22 A
23 A
24 A
25 A

php_questions_answers.htm

Useful Video Courses

Which of the following is correct about constants vs variables in php

Video

Which of the following is correct about constants vs variables in php

Video

Which of the following is correct about constants vs variables in php

Video

Which of the following is correct about constants vs variables in php

Video

Which of the following is correct about constants vs variables in php

Video

Which of the following is correct about constants vs variables in php

Video

Which of the following are correct about constants vs variables in PHP?

Q 3 - Which of the following is correct about constants vs variables in PHP? A - Constants may be defined and accessed anywhere without regard to variable scoping rules.

Which of the following is a correct way to declare constant variable in PHP?

A valid constant name starts with a letter or underscore (no $ sign before the constant name). Note: Unlike variables, constants are automatically global across the entire script.

Which of the following is true about PHP variables?

Q 9 - Which of the following is true about php variables? A - All variables in PHP are denoted with a leading dollar sign ($).

What is difference between variable and constant?

What is the Difference between Constant and Variables? A constant does not change its value over time. A variable, on the other hand, changes its value dependent on the equation. Constants are usually written in numbers.