Forum Moderators: coopster
function something() {
echo "heaps of text"; }
if ( strlen(something()) == 0 ) {
echo "the function didn't say anything"; }
else { something(); }
you see, the output of the code above, if it works, would put "heaps of text" on the screen. but the stuff being echoed by my function changes depending on certain variables and sometimes the echo is empty because, depending on what the function finds, there may be nothing to echo. if there is nothing to echo, i want to display a message ("the function didn't say anything", or something to the sort)
No, that will not work. One way you can do it is to pass the text into a function and return its length:
function something($text) {
return strlen($text); }
echo something("Heaps of Text");
This should echo 13.
Then you could use:
if ( something() == 0 ) {
echo "the function didn't say anything"; }
else { something(); }
That help any?