question about functions

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!

Moderator: General Moderators

Post Reply
chris12295
Forum Contributor
Posts: 113
Joined: Sun Jun 09, 2002 10:28 pm
Location: USA
Contact:

question about functions

Post by chris12295 »

I need to write a block of code and use it over and over in my script with a simple declaration. Kind of like functions in Javascript. Somthing like

function fizzlePants {

echo "blah"

}

if(blah) {
return fizzlePants
}

I know that wont work at all but its the concept im after. Can anyone help?
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

Code: Select all

function fizzlePants(){
echo "blah blah blah";
}

fizzlePants();

will print "blah blah blah"

Code: Select all

function fizzlePants(){
echo "blah blah blah";
}
if($blah){
fizzlePants();
}
will print "blah blah blah" if the variable Blah is true

Code: Select all

$blah = "ack";
function fizzlePants($foo){
echo "blah blah blah $blah $blah $blah";
}
if($blah){
fizzlePants($blah);
}
will print "blah blah blah ack ack ack" if the variable Blah is true..

i would still reccomend you read a tutorial on functions though... there is alot to say about them
Post Reply