Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End ID the Body Based on URL – WordPress/PHP Re: ID the Body Based on URL – WordPress/PHP

#72560
Rob MacKay
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?