- Joined
- May 11, 2008
- Messages
- 513
- Reaction score
- 99
Okay functions are a simple way of organising code in a structured maner, I would always suggest using functions because you don't have to copy and paste the same code over and over again! It's amazing. You can even have two seperate php files linked with the include(); pre-set function (I'll show you in a bit ). Which would save you time copy and pasting, I'd also like to save I've always been one from just looking at the code I learn from it, so i'm sorry if It's not explained that well. :$: any i'm just chatting 'breeze' now, so lets get to the hardcore sheit.
How to make a function
Simples.
How do you excute a function
How to get an output from your function
Amazing Huh?
But thats pointless, not really Lets do some more Advanced stuff(well ish)
What about this now an IF statement in a function! :O
Enjoy, Any questions just ask below.
How to make a function
PHP:
<?php
function YOURFUNCTIONNAME()
{
}
?>
How do you excute a function
PHP:
<?php
function YOURFUNCTIONNAME()
{
}
// this line below will excute it! Yay ;]
YOURFUNCTIONNAME();
?>
PHP:
<?php
function YOURFUNCTIONNAME()
{
return 'Bob';
}
echo YOURFUNCTIONNAME(); // Gets Bob
?>
But thats pointless, not really Lets do some more Advanced stuff(well ish)
PHP:
<?php
function YOURFUNCTIONNAME($str)
{
return $str;
}
echo YOURFUNCTIONNAME("Bob");
?>
PHP:
<?php
function YOURFUNCTIONNAME($sr)
{
if($str != "Bob")
{
return "Who are you?";
}
else
{
return "Howdy Bob! :)";
}
}
// this line below will excute it! Yay ;]
echo YOURFUNCTIONNAME("Bob");
echo YOURFUNCTIONNAME("James");
?>
Enjoy, Any questions just ask below.