<?php
$x=5; // globel scope
function myTest() {
// using x inside a function is generate an error
echo "<p>variable x inside function is: $x</p>";
}
myTest();
echo "<p>variable x inside function is: $x</p>";
?>
Warning: Undefined variable $x in /in/SVcUE on line 6
<p>variable x inside function is: </p><p>variable x inside function is: 5</p>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Warning: Undefined variable $x in /in/SVcUE on line 6
<p>variable x inside function is: </p><p>variable x inside function is: 5</p>