Interne variable i PHP-funktioner
Variable erklæret inde i en funktion er ikke synlige udefra. Lad os se på et eksempel. Antag, at vi har følgende variabel:
<?php
function func()
{
$num = 1;
}
?>
Lad os prøve at udskrive
variablen $num udenfor
funktionen:
<?php
function func()
{
$num = 1;
}
func();
echo $num; // fejl
?>
Forklar, hvad resultatet af at køre koden vil være:
<?php
function func()
{
$aaa = '!!!';
}
func();
echo $aaa;
?>
Forklar, hvad resultatet af at køre koden vil være:
<?php
function func($aaa)
{
$aaa = 222;
}
func(111);
echo $aaa;
?>