Variable Scope: A Variable Declared Within a Function Is Unavailable Outside the Function : Variable Scope « Language Basics « PHP






Variable Scope: A Variable Declared Within a Function Is Unavailable Outside the Function

 
<html>
<head>
<title>Local Variable Unavailable Outside a Function</title>
</head>
<body>
<div>
<?php
    function test() {
       $testvariable = "this is a test variable";
    }
    print "test variable: $testvariable<br/>";
?>
</div>
</body>
</html>
  
  








Related examples in the same category

1.Variable scope: function
2.Use variable defined outside function
3.Scope of a Variable
4.Variable Scope: A Variable Declared Within a Function Is Unavailable Outside the Function
5.Variables Defined Outside Functions Are Inaccessible from Within a Function by Default
6.Defining Variable Scope
7.More Working with Variable Scope
8.local variables
9.Variable Scope
10.Variable Scope in Functions