PHP MCQ

PHP MCQ | PHP MCQ Questions And Answers

PHP MCQ. PHP Multiple-Choice questions and answers. The correct answer is highlighted in every MCQ. For Javascript Multiple-Choice questions visit Javascript MCQs

 

PHP MCQ

 

A script is what ??

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 the only
d. None of above

 

When do 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( );

 

When compared to the compiled program, scripts run how ??

a. Faster
b. Slower
c. The execution speed is similar
d. All of above

 

A variable $word is set to “HELLO WORLD”, which of the following script returns in the title case ??

a. echo ucwords($word)
b. echo ucwords(strtolower($word)
c. echo ucfirst($word)
d. echo ucfirst(strtolower($word)

 

PHP is a widely used _____ scripting language that is especially suited for web development and can be embedded into HTML ??

a. Open source general-purpose
b. Proprietary general-purpose
c. Open source special purpose
d. Proprietary special purpose

 

When a file is included in the code it contains, behaves for the variable scope of the line on which the include occurs ??

a. Any variable available at that line in the calling file will be available within the called file from that point
b. Any variable available at that line in the calling file will not be available within the called file
c. Variables are local in both called and calling files
d. None of above

 

Which of the following is not true ??

a. PHP can be used to develop web applications
b. PHP makes a website dynamic
c. PHP applications can not be compiled
d. PHP can not be embedded into HTML

 

Which of the following method sends input to a script via a URL ??

a. Get
b. Post
c. Both
d. None

 

Which of the following method is suitable when you need to send larger form submissions ??

a. Get
b. Post
c. Both Get and Post
d. There is no direct way for a larger form. You need to store them in a file and retrieve

 

Which of the following variables is not a predefined variable ??

a. $get
b. $ask
c. $request
d. $post

 

PHP MCQ

Which of the following mode of the fopen() function opens a file only for writing. If a file with that name does not exist, attempt to create a new file. If the file exists, place the file pointer at the end of the file after all other data ??

a. W
b. W+
c. A
d. A+

 

You can define a constant by using the define() function. Once a constant is defined then ??

a. It can never be changed or undefined
b. It can never be changed but can be undefined
c. It can be changed but can not be undefined
d. It can be changed and can be undefined

 

The function setcookie( ) is used to ??

a. Enable or disable cookie support
b. Declare cookie variables
c. Store data in cookie variable
d. All of above

 

To work with remote files in PHP you need to enable what ??

a. allow_url_fopen
b. allow_remote_files
c. both of above
d. none of above

 

Which of the following function returns the number of characters in a string variable ??

a. count($variable)
b. len($variable)
c. strcount($variable)
d. strlen($variable)

 

fopen($file_doc,”r+&rdquo Wink opens a file for ??

a. reading
b. writing
c. none of above
d. both of above

 

In mail($param2, $param2, $param3, $param4), the $param2 contains ??

a. The message
b. The recipient
c. The header
d. The subject

 

Trace the odd data type is ??

a. floats
b. integer
c. doubles
d. Real number

 

mysql_connect( ) does not take the following parameter ??

a. database host
b. user ID
c. password
d. database name

 

Which of the following are valid float values ??

a. 4.5678
b. 4.0
c. 7e4
d. All of above

 

PHP MCQ

 

Study following steps and determine the correct order ??
(1) Open a connection to the MySql server
(2) Execute the SQL query
(3) Fetch the data from a query
(4) Select the database
(5) Close Connection

a. 1, 4, 2, 3, 5
b. 4, 1, 2, 3, 5
c. 1, 5, 4, 2, 1
d. 4, 1, 3, 2, 5

 

In PHP string data are ??

a. delimited by single quote
b. delimited by double quote
c. delimited by <<< identifier
d. All of above

 

Which of the following is not a session function ??

a. sssion_decode
b. session_destroy
c. session_id
d. session_pw

 

Which of the following delimiting method is known as string Interpolation ??

a. delimited by single quote
b. delimited by double quote
c. delimited by <<< identifier
d. All of above

 

When uploading a file if the UPLOAD_ERR-OK contains value 0 it means ??

a. Upload is not successful, an error occurred
b. The file uploaded with success
c. The uploaded file size is 0
d. File upload progress is 0% completed

 

Which data types are treated as arrays ??

a. Integer
b. Float
c. String
d. Booleans

 

Which of the following delimiter syntax is PHP’s default delimiter syntax ??

a. <? php ?>
b. <% %>
c. <? ?>
d. <script language=”php”> </script>

 

Which of the following are compound data types??

a. Array
b. Objects
c. Both
d. None

 

Which of the following statement produce different output ??

a. <?echo “This is php example”; ?>
b. <P=”This is php example”; ?>
c. <?PHP echo “This is php example”; php?>
d. <script language=”php”> print “This is php example”;</script>

 

The casting operator introduced in PHP 6 is ??

a. (array)
b. (int64)
c. (real) or (double) or (float)
d. (object)

 

PHP MCQ

 

Which of the following delimiter is ASP style ??

a. < >
b. <% %>
c. <? ?>
d. <script language=”php”> </script>

 

When defining identifier in PHP you should remember that ??

a. Identifier is case sensitive. So $result is different than $ result
b. Identifiers can be any length
c. Both of above
d. None of above

 

PHP supports all four different ways of delimiting. In this context identify the false statement ??

a. You can use any of the delimiting styles
b. You can use different delimiting styles on the same page
c. You can use any delimiting style but must use a single style consistently for a page
d. Variables declared in previous blocks are remembered on later blocks too

 

Identify the invalid identifier ??

a. my-function
b. size
c. –some word
d. This&that

 

Which of the following commenting is supported by Php ??

a. Single line c++ syntax – //
b. Shell syntax – #
c. Both of above
d. None of above

 

Which of the following variable assignments is a ‘by value’ assignment in PHP ??

a. $value1= $value?
b. $value1= & $value?
c. $value1= & $value?
d. None

 

To produce the output6 I love the summertime, Which of the following statement should be used ??

a. <? Php print (“<P> I love the summer time</p>”Wink;?>
b. <? Php $ season=”summer time”; print”<p> I love the $ season</p>”; ?>
c. <?Php $ message=”<p> I love the summer time </p>; ecdho $ message; ?>
d. All of above

 

Identify the variable scope that is not supported by PHP ??

a. Local variables
b. Function parameters
c. Hidden variables
d. Global variables

 

Which of the following functions return 1 when output is successful ??

a. echo ( )
b. print ( )
c. both
d. None

 

What will be the output of the following PHP code ??

$somerar=15;
function ad it () {
GLOBAL $somevar;
$somerar++ ;
echo “somerar is $somerar”;
}
addit ();

a. somerar is 15
b. somerar is 16
c. somerar is 1
d. somerar is $ somerar

 

PHP MCQ

Which of the following statements is more suitable if you want to output a blend of static text and dynamic information stored within one or several variables?

a. echo ( )
b. print ( )
c. Print f ( )
d. None of above

 

The variable scope on which a variable does not lose its value when the function exists and use that value if the function is called again is ??

a. Local
b. function parameter
c. static
d. None of above

 

Which of the following type specifier is invalid in print f ( ) functions ??

a. % a
b. % b
c. % c
d. % d

 

The left association operator % is used in PHP for ??

a. percentage
b. bitwise or
c. division
d. modulus

 

Which of the following function can assign the output to a string variable ??

a. echo ( )
b. print ( )
c. print f ( )
d. sprint f ( )

 

The left-associative dot operator (.) is used in PHP for ??

a. multiplication
b. concatenation
c. separate object and its member
d. delimeter

 

Which of the following data type is not sealed or data types supported by PHP ??

a. Array
b. String
c. Float
d. Boolean

 

Which of the following statement is false ??

a. Any code found within an included file will inherit the variable scope of the location of its caller
b. Because the included code will be embedded in a PHP execution block, the PHP execution block, the PHP escape tags (<?php?>Wink aren’t required on the file to be included
c. For the inclusion of remote files the allow-url-pope must be enabled ad URL wrapper must be supported
d. Including a file produces the same result as copying the data from the file specified into the location in which the statement appears

 

Which of the following data type is compound datatype supported by PHP ??

a. Array
b. String
c. Float
d. Boolean

 

Which of the following functions require the allow-url-fopen must be enabled ??

a. include()
b. require()
c. both of above
d. None of above

 

PHP MCQ

If a boolean variable $ alive= 5; ??

a. $ alive is false
b. $ alive is true
c. $ alive is overflow
d. the statement is not valid

 

Which function includes the specified file even the statement evaluates to false in which block the function is placed ??

a. include ()
b. require ()
c. both of above
d. None of above

 

For integer data type PHP 6 introduced ??

a. 8-bit integer value
b. 16-bit integer value
c. 32-bit integer value
d. 64-bit integer value

 

On failure of which statement the script execution stops displaying error/warning message ??

a. rinclude ()
b. require ()
c. both of above
d. None of above

 

For integer data type PHP 5 and earlier supported ??

a. 8-bit integer value
b. 16-bit integer value
c. 32-bit integer value
d. 64-bit integer value

 

Trace the function that does continue the script execution even if the file inclusion fails ??

a. include ()
b. require ()
c. both of above
d. None of above

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!