Internal Function Variables in PHP
Variables declared inside a function are not visible outside. Let's look at an example. Suppose we have the following variable:
<?php
function func()
{
$num = 1;
}
?>
Let's try to output
the variable $num
from outside
the function:
<?php
function func()
{
$num = 1;
}
func();
echo $num; // error
?>
Explain what the result of the code execution will be:
<?php
function func()
{
$aaa = '!!!';
}
func();
echo $aaa;
?>
Explain what the result of the code execution will be:
<?php
function func($aaa)
{
$aaa = 222;
}
func(111);
echo $aaa;
?>