php - Why this code giving output 200? -


solve problem please...

function abc($a, $b) {      echo  $c = $a+$b; }  echo   0*( abc(10,10)  ); // giving output 200!!!!! echo "<br />"; echo   6*( abc(10,10)  ); //giving output 200!!!!!  echo "<br />"; echo   30*( abc(10,10)  ); //giving output 200!!!!! 

any 1 in this?

what echo 0 * (echo (10 + 10)). precedence of parenthesis, first echo 10 + 10 (= 20), echo 0 * (void) , seems void implicitly cast int(0), void return of function abc, output 200.

6 * void , 30 * void = 0 either, output same.

edit: is, step step, happens: echo 0 * (abc(10 + 10)):

1) calls abc

2) echoing 10 + 10 (so outputs 20 @ moment.)

3) returning abc (it returns void because don't specify return value)

4) evaluates 0 * (abc(10 + 10)) = 0 * void = 0 * 0 = 0

5) echoing 0 (so ouputs 0 right after 20 step 2) ).

the steps second , third lines same, since 6 * 0 , 30 * 0 equals 0 too.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -