Variables Defined Outside Functions Are Inaccessible from Within a Function by Default : Variable Scope « Language Basics « PHP
- PHP
- 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>
Related examples in the same category