functionlike so then you give the function a name
function mycat()
{
//Block of code goes here
}
So say you wanted to have a function that protects variables when inserted in a database you could do this
function protect($value){
$value = mysql_real_escape_string($value);
return $value;
}
So this code creates a function that uses mysql_real_escape_string to protect any variable you might like if your inserting it into a database to use this function just call it like this.
$myvariable = protect($_POST['name']);
So as you can see we wrapped our function around $_POST['name'] this will protect whatever value name is when inserted into a mysql database.
To simply output something that is inside a function you would do this
function hello(){
echo "HELLO WORLD!";
}
Then call this function like this
hello();
And that when ran will print out HELLO WORLD!
so this was a short tutorial on functions and how to
use them in php if you
like this tutorial give me a +1 thanks
Help
















