View Single Post
Old 02-07-2013, 02:07 PM   PM User | #1
sunilmkt
New Coder

 
Join Date: Jan 2013
Location: India
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
sunilmkt can only hope to improve
How to define Variable Scope in Php?

If you define a variable within a function that means variable is only available within that function. This variable cannot CALL in another function or in the body of your program code. These types of variable are known as a variable's scope. The scope of a variable defined within a function is local to that function. If you want to use variable that is defined in the main body of program code. Remember It must reference using global keyword.
<?php
function_SubNumber ( )
{
global $sum = 4 - 4
}

$sum = 0
Subnumber ( )
echo "4 - 4 = ".$sum
?>
sunilmkt is offline   Reply With Quote