Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
A variable declared within a function has a LOCAL SCOPE and can only be accessed within that function:
SUBMITTED BY:
henry1874w
DATE:
June 4, 2017, 7:56 p.m.
FORMAT:
Text only
SIZE:
236 Bytes
Raw
Download
Tweet
HITS:
211
Go to comments
Report
<?php
function myTest() {
$x = 5; // local scope
echo "<p>Variable x inside function is: $x</p>";
}
myTest();
// using x outside the function will generate an error
echo "<p>Variable x outside function is: $x</p>";
?>
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus