×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

What will be the output of the following PHP code (26)?

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

<?php declare(strict_types = 1);

function details(string $name, int $age){
    echo "Name: $name, Age: $age";
}
details("Alvin", "21");
?>
  1. Name: Alvin, Age: 21
  2. Name: Alvin, Age:
  3. Name: Alvin, Age: 0
  4. Fatal Error

Answer: D) Fatal Error

Explanation:

In the PHP Script, we are using the strict declaration, it will return a Fatal Error if the datatype of the function definition and calling mismatches. Thus, the output will be "Fatal Error".

The output is:

PHP Fatal error: Uncaught TypeError: Argument 2 passed to details() must be of the type integer, 
string given, called in /home/fBGU1n/prog.php on line 6 and defined in 
/home/fBGU1n/prog.php:3 Stack trace: #0 /home/fBGU1n/prog.php(6): details('Alvin', '21') #1 {main} thrown 
in /home/fBGU1n/prog.php on line 3

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.