PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function some_function(){
$a=$a+100;
// if it was expected to return a value then return a value..if not print the value
if (something) {
return $a;
}else{
print $a;
}
}
$a=some_function(); //this returns the value into a
some_function(); // this prints the value
yeah I was thinking of passing a paramater but it seems silly.
Why is it bad practice out of interest.
Basically I've made a helper for creating hyperlinks (a la codeigniter/RoR) and I'd like to print the hyperlinks if it is simply called and return the hyperlinks if it is assigned to a variable. because sometimes I might want to return the a hyperlinks that is created to pass it into another helper.