
Create your own Functions
1. An Introduction to Functions
A function is just a piece of code,that you want to use not once but again and again. Functions save you from writing the code again and again. A function always return a value.
2. Variable scope and functions
function function_name( )
{
}
3. Functions and Arguments
You can pass variable to your functions by typing them inside of the round brackets of the function name.
<?
function myFunction($variable1,$variable2)
{
echo $variable1;
}
// Using Function
$variable1="Some Text";
$variable2=100;
myFunction($variable1,$variable2);
?>
4. Getting values out of functions
Getting some calculated value from function.
Get a discout value.
<?
$spent_money = 150;
echo calculate($spent_money);
function calculate($spent_money)
{
$discount = 0.1;
if ($spent_money > 100)
{
$discount_total = $spent_money - ($spent_money * $discount);
$discount = $discount_total;
}
else
{
$discount = "No discount";
}
return $discount;
}
?>
5. HTTP Header() Function
<?
header("Location: http://www.visualbuilder.com/");
?>
6. The INCLUDE( ) Function
<? include "somefile.txt" ; ?>
Php Discussion
- - PHP 4 or 5 as a Deploymen
- - How do I decode a html/ph
- - PHP help
- - What is wamp?
- - How to execute a php file
Php Source Code
- - Wraps A String To A Given
number Of Characters Using A
string Break Character - - Uppercase The First Character
of Each Word In A String - - Make A String's First Character
uppercase - - Strip Whitespace (or Other
characters) From The Beginning
and End Of A String - - Return Part Of A String




