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<?php
  function func()
  {
    $num = 1;
  }
?>

Lad os prøve at udskrive variablen $num udenfor funktionen:

php<?php
  function func()
  {
    $num = 1;
  }
  
  func();
  echo $num; // fejl
?>
Задание 1

Forklar, hvad resultatet af at køre koden vil være:

php<?php
  function func()
  {
    $aaa = '!!!';
  }
  
  func();
  echo $aaa;
?>
Задание 2

Forklar, hvad resultatet af at køre koden vil være:

php<?php
  function func($aaa)
  {
    $aaa = 222;
  }
  
  func(111);
  echo $aaa;
?>