TerraBuilder Posted December 26, 2009 Share Posted December 26, 2009 I wrote a statement to display a number and write a string true or false after testing it to be a double. Although, if I write it in the first echo statement, it goes out of order. This wont happen if I separate into another echo statement on the next line. <? function check($num){ //function to change if(is_double($num)){ echo "TRUE"; }else{ echo "FALSE"; } } $number=3.1415; echo "Is ".$number." a double?".check($number); //Output ?> Link to comment https://forums.phpfreaks.com/topic/186387-wrong-order-of-output/ Share on other sites More sharing options...
rajivgonsalves Posted December 26, 2009 Share Posted December 26, 2009 echo true or false in the function will run before the echo of your main statement will, you should use return, your should have been, I just shorten the code a bit. <?php function check($num){ //function to change return is_double($num) ? "TRUE" : "FALSE"; } $number=3.1415; echo "Is ".$number." a double?".check($number); //Output ?> Link to comment https://forums.phpfreaks.com/topic/186387-wrong-order-of-output/#findComment-984277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.