Variables Defined Outside Functions Are Inaccessible from Within a Function by Default : Variable Scope : Language Basics PHP Source Code


PHP Source Code » Language Basics » Variable Scope »

 

Variables Defined Outside Functions Are Inaccessible from Within a Function by Default







<html>
<head>
<title>Variables Defined Outside Functions Are Inaccessible from Within a Function by Default</title>
</head>
<body>
<?php

$life = 42;

function meaningOfLife(){
     print "The meaning of life is $life<br>";
}

meaningOfLife();

?>
</body>
</html>

           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Language Basics
» Variable Scope