1. Which of the below statements is equivalent to $add += $add?
a) $add = $add + $add + 1
b) $add = $add +$add
c) $add = $add + 1
d) $add = $add
Explanation: a += b is an addition assignment whose outcome is a = a + b. Same can be done with subtraction, multiplication, division etc.
2. PHP files have a default file extension of_______.
a) .html
b) .xml
c) .php
d) .hphp
Explanation: To run a PHP file on the server, it should be saved as lfc.php.
3. A script is a_______.
a) Program or sequence of instructions that is interpreted or carried out by processor directly
b) Program or sequence of instruction that is interpreted or carried out by another program
c) Program or sequence of instruction that is interpreted or carried out by web server only
d) None of the above
Explanation: A script is a program or sequence of instruction that is interpreted or carried out by another program.
4. Which one of the following PHP functions can be used to find files?
a) fold()
b) file()
c) glob()
d) get_file()
Explanation: The function glob() returns an array of filenames or directories which matches a specified pattern. The function returns an array of files/directories, or it will return FALSE on failure.
5. When you need to obtain the ASCII value of a character which of the following function you apply in PHP?
a) chr( );
b) asc( );
c) ord( );
d) val( );
Explanation: When we need to obtain the ASCII value of a character we apply ord( ); in PHP.
6. A variable name can only contain ____________?
a) alphanumeric characters
b) underscores
c) Both A and B
d) None of the above
Explanation: A variable name can only contain alphanumeric characters and underscores in their name.
7. Which one of the following PHP function is used to determine a file’s last access time?
a) fileatime()
b) filectime()
c) fileltime()
d) filetime()
Explanation: The fileatime() function returns a file’s last access time in Unix timestamp format or FALSE on error.
8. Which one of the following function is capable of reading a specific number of characters form a file?
a) fgets()
b) fget()
c) fileget()
d) filegets()
Explanation: Its prototype is string fgets(resource handle [, int length]). If the optional length parameter is omitted, 1024 character is assumed.
9. PHP variables are case-sensitive?
a) True
b) False
c) For "sum" variable it is case-sensitive
d) None of the above
Explanation: PHP variables are case-sensitive, i.e., $lfc and $LFC are treated differently.
10. What will be the output of the following PHP code?
<?php
$a = 1;
$b = 2;
$c = 3;
echo ($a * (($b) - $c));
?>
a) 1
b) -1
c) 2
d) -2
Explanation: The innermost bracket is evaluated first since it covers only variable B, it is as good as not using brackets, then $b- $c action will be performed.