What will be the output of the following php code php function addition num num 2 num echo num

This set of PHP Multiple Choice Questions & Answers [MCQs] focuses on “Functions – 2”.

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

a] Error
b] 49
c] 1
d] Sum
View Answer

Answer: c
Explanation: It is possible to call a function using a variable which stores the function name also the chr[] function returns a character from the specified ASCII value.

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

a] 0
b] 1
c] 0.5
d] -0.5
View Answer

Answer: b
Explanation: cos[] gives the cos value of the argument. Here the function returns 1.

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

a] b is executedb is executedb is executed
b] b is executeda is executed
c] a is executed
d] b is executeda is executedb is executed
View Answer

Answer: d
Explanation: Simple order of execution.

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

a]

  5 + 10 = 15
  2 + 4 = 6
  7 + 13 = 20

b]

  7 + 13 = 20
  5 + 10 = 15
  2 + 4 = 6

c]

  5 + 10 = 15
  7 + 13 = 20
  2 + 4 = 6

d]

  5 + 10 = 20
  7 + 13 = 6
  2 + 4 = 15

View Answer

Answer: d
Explanation: The function calls are jumbled.

  

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

a]

Original Value is 15
Original Value is 21

b]

Original Value is 15
Original Value is 21 

c]

Original Value is 15
Original Value is 15

d] None Of The mentioned
View Answer

Answer: b
Explanation: addSix[] passes value of the variable by reference.

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

a] Returned value from the function : $return_value
b] Error
c] Returned value from the function : 30
d] Returned value from the function :
View Answer

Answer: c
Explanation: Functions returns value 30.

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

a] No Output
b] Error
c] sayHello
d] HelloWorld
View Answer

Answer: d
Explanation: It is possible to assign function names as strings to variables and then treat these variables exactly as you would the function name itself.

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

a] error
b] this works
c] this worksthis too works
d] this works this too works
View Answer

Answer: c
Explanation: Two is declared in one and is called after one. Hence it works.

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

a] 4
b] 5
c] 2
d] None of the mentioned
View Answer

Answer: a
Explanation: Donkey starts from position 4 in string.

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

a] I am awesome!!
b] const
c] const, I am awesome!!
d] “const”,”I am awesome!”
View Answer

Answer: a
Explanation: Using the define function to define the constant “const”.

Sanfoundry Global Education & Learning Series – PHP Programming.

To practice all questions on PHP Programming, here is complete set of 1000+ Multiple Choice Questions and Answers on PHP.

Next Steps:

  • Get Free Certificate of Merit in PHP Programming
  • Participate in PHP Programming Certification Contest
  • Become a Top Ranker in PHP Programming
  • Take PHP Programming Tests
  • Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  • Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.

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

What will be the output of the following PHP code? Explanation: The statement should be print_r['Hello World'] to print Hello world. Also if there is only one line then there is no requirement of a semicolon, but it is better to use it. Get Free Certificate of Merit in PHP Programming Now!

What is the output of PHP script ?

Answer. It output one or more strings. We can use 'echo' to output strings, numbers, variables, values, and results of expressions.

What will be the output of the following PHP code

Chủ Đề