Php programming language MCQ : Function and String : Link4

Php programming language MCQ : Function and String(Comparing strings) : Link4

Function and String MCQ

       Are you worried about the answers to PHP programming-Function and String-Default parameters, Variable function, Anonymous function, Types of strings in PHP, Encoding and escaping, Comparing strings, Manipulating and searching strings, Regular expressions questions? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Function and String MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. What will be the output of the following code.

 <?php \\
     \$language = function(\$name) \\
     \{ \\
         printf("\%s\:totalmcq.com\:\:",\$name); \\
                 \}; \\
                 \$language('www.');\\
?>







A. www.totalmcq.com                                                              B. totalmcq.com
C. www.                                                       D. Generates Error

Q.2. PHP5 introduced a new feature known as ------- which gives you the ability to force parameters to be objects of a certain class or to be arrays.

A. parameters hinting                                             B. type hinting
C. objects hinting                                           D. hinting

Q.3. State whether the following statements on return statements are True or False.
i) If return() is called from within the global scope, the script execution is terminated.
ii) A function can also return multiple values without using an array.
iii) If the return() is omitted the value NULL will be returned.

A. i-True, ii-False, iii-False
B. i-True, ii-True, iii-True 1
C. i-True, ii-False, iii-True inf
D. i-True, ii-True, iii-False

Q.4. What will be the output of the following PHP code.

 <?php \\
     function\:\:display(\$a) \\
     \{ \\
         if(\$a < 30 ) \\
                 \{ \\
             echo \:\:"\$a \:\;\:\:" ;   \\
                 display(\$a+1);\\
 \} \\
 \} \\
echo \: display(29) \\
?>






A. 30
B. 29 30
C. 29
D. Null

Q.5. State whether the following statements on return type declarations are True.
i. Return type declarations specify the type of value that will be returned from a function.
ii. When overriding a parent method, the child’s method must match any type of declaration on the parent.

A. i only
B.ii only
C. Both i and ii
D. None of the above

Q.6. Arrow functions support the same features as ------- except that using variables from the parent scope is always automatic.

A. Variable functions
B. Static functions
C. Anonymous functions
D. Both A and C

Q.7. POSIX stands for--------

A. Portable Operating System Interface for Unix
B. Portable Operating System Interface for Linux
C. Portative Operating System Interface for Unix
D. Portative Operating System Interface for Linux

Q.8. Which of the following statements are True about the variable functions on PHP.
i. PHP will look for a function with the same name as whatever the variable values to it.
ii. Variable functions won’t work with language constructs.
iii. Object methods can not be called with the variable functions.

A. i-True, ii-False, iii-False
B. i-True, ii-True, iii-True
C. i-True, ii-False, iii-True
D. i-True, ii-True, iii-False

Q.9. State Whether the following statements are True or False.
i. Anonymous functions are also known as closures.
ii. Closures can also be used as the value of variables.
iii. Closures can not inherit variables from the parent scope.

A. i-True, ii-False, iii-False
B. i-True, ii-True, iii-True
C. i-True, ii-False, iii-True
D. i-True, ii-True, iii-False

Q.10. ------- are used to represent a list or range of characters to be matched.

A. []                                                                                B. {}
C. ()                                                                             D. /*