Thanks a ton for all the feedback! This forum is really useful!
The 'hidden' thing wouldn't work though, because this is part of an Ajax page updater and I want to make sure to save as much bandwidth as possible.
That's why I'm using md5 to check if there is new content.
I eventually solved my problem by replacing printf with sprintf and storing (with .=) everything in a variable which is then returned.
So my problem was pretty much solved in the end anyway.
Thank you everybody once again for the feedbackz0rz!
Function echo/print problem
Moderator: General Moderators
Re: Function echo/print problem
excellent, I was just looking into sprintf on google for you... lol
Glad you have sorted out the issue you were having... its hard to get a full picture of what you are trying to achieve without all the coding to see the full story. Well done pal.
Jason.
Glad you have sorted out the issue you were having... its hard to get a full picture of what you are trying to achieve without all the coding to see the full story. Well done pal.
Jason.
Re: Function echo/print problem
Agree lol.phphelpme wrote:its hard to get a full picture of what you are trying to achieve without all the coding to see the full story.
sprintf would be good, something like;
Code: Select all
<?php
function foo() {
$apples = 36;
$trees = 5;
$monkeys = 1;
$bananas = 56;
$string = sprintf("There are %2$s apples in the %1$s trees with %s monkeys and %s bananas.<br />", $apples, $trees, $monkeys, $bananas);
$bees = 234;
$dogs = 2;
$string .= sprintf("There are %d bees, and %d dogs.", $bees, $dogs);
return $string;
}
$bar = md5(foo());
echo $bar;
?>