ryy705 Posted November 19, 2008 Share Posted November 19, 2008 Hello, The following code prints out 0. Does anyone know why? I expected it to print 36. <?php function a($number) { return (b($number) * $number); } function b(&$number) { ++$number; } echo a(5); ?> Link to comment https://forums.phpfreaks.com/topic/133417-solved-why-does-it-print-0/ Share on other sites More sharing options...
DarkWater Posted November 19, 2008 Share Posted November 19, 2008 b() doesn't return anything, and 0 * 6 is 0. EDIT: This should work though: <?php function a($number) { return (b($number) * $number); } function b(&$number) { return ++$number; } echo a(5); ?> Link to comment https://forums.phpfreaks.com/topic/133417-solved-why-does-it-print-0/#findComment-693904 Share on other sites More sharing options...
ryy705 Posted November 20, 2008 Author Share Posted November 20, 2008 I see it now. Thanks. Link to comment https://forums.phpfreaks.com/topic/133417-solved-why-does-it-print-0/#findComment-694003 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.