Heim >Backend-Entwicklung >PHP-Tutorial > php 的引述传值

php 的引述传值

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 13:05:40818Durchsuche

php 的引用传值
php 函数传值 方式,数值传值,引用传值(&)


$app = array(
'a',
'b',
'c',
);
echo $app[0]."\n";


function modify_aa($a){

  if(is_array($a)){
      $a[0]="1";
    }
}
function modify_bb(&$a){

  if(is_array($a)){
      $a[0]="1";
    }
}
modify_aa($app);

echo $app[0]."\n";
modify_bb($app);
echo $app[0]."\n";

结果
a
a
1

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn