Home › Forums › Back End › ID the Body Based on URL – WordPress/PHP › Re: ID the Body Based on URL – WordPress/PHP
November 23, 2010 at 5:52 am
#72560
Participant
yea you need to either return OR echo, you can’t return echo $dir.
Return is used in functions to pass a value back – but dosen’t need to echo it.
For example to display the text “Garry”:
function name() {
$e = "Garry";
return $e;
}
echo name(); //this would NEED echo because the return dosen't echo.
or
function name() {
$e = "Garry";
echo $e;
}
name(); //this would NOT need echo because the echo is already in the function.
The best practice is to return the value and then echo it out.
It might work after that because you are actually returning a value, where as before you were not.
Does that make sense?