Function not working as expected in PHP -


what wrong output of function, prints out inf int browser expected print out 654321 exact same function written in c# print out expected result.

<?php         function reverse($n, $r){             if($n == 0) {                 return $r;             }             return reverse($n/10, $r*10 + $n%10);         }          echo reverse(123456, 0); ?> 

it not integer division. in c# deal strict typing, , when divide 25 4 in c# integer result, 6. in php 6.25, float result.

try intval results before recursion integer division


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -