PHP'de Fonksiyon Parametrelerinin Değiştirilmesi

Fonksiyona parametre olarak iletilen değişkenlerin değiştirilmesi, bu değişkenlerin fonksiyon dışındaki değerlerini değiştirmez:

php<?php
  function func($bbb)
  {
    $bbb = 2;
  }
  
  $aaa = 1;
  func($aaa);
  echo $aaa; // 1
?>

Bu, dış ve iç değişkenlerin aynı isme sahip olması durumunda da çalışır:

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

Aşağıdaki kodun çalıştırılması sonucu ne olur?

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

Aşağıdaki kodun çalıştırılması sonucu ne olur?

php<?php
  $aaa = 'a';
  
  function func($bbb)
  {
    $bbb = 'b';
  }
  
  func($aaa);
  echo $bbb;
?>
Задание 3

Aşağıdaki kodun çalıştırılması sonucu ne olur?

php<?php
  $str = 'a';
  
  function func($str)
  {
    $str = 'b';
  }
  
  func($str);
  echo $str;
?>
Задание 4

Aşağıdaki kodun çalıştırılması sonucu ne olur?

php<?php
  $arr = [1, 2, 3, 4, 5];
  
  function func($arr)
  {
    $arr[0] = '!';
  }
  
  func($arr);
  var_dump($arr);
?>