关于引用, 这种情况谁能解释下
代码段1:
<br />$array_a = array( 0 => 'a' );<br />$array_b = &$array_a;<br />$array_c = &$array_b;<br />$array_d = $array_b;<br /><br />$array_c[0] = 'b';<br /><br />echo '变量a:';var_dump( $array_a );<br />echo '变量b:';var_dump( $array_b );<br />echo '变量c:';var_dump( $array_c );<br />echo '变量d:';var_dump( $array_d );<br />
<br />变量a:<br />array (size=1)<br /> 0 => string 'b' (length=1)<br />变量b:<br />array (size=1)<br /> 0 => string 'b' (length=1)<br />变量c:<br />array (size=1)<br /> 0 => string 'b' (length=1)<br />变量d:<br />array (size=1)<br /> 0 => string 'a' (length=1)<br />
<br />$array_a = array( 0 => 'a' );<br />$array_b = &$array_a;<br />$array_c = &$array_b[0];<br />$array_d = $array_b;<br /><br />$array_c = 'b';<br /><br />echo '变量a:';var_dump( $array_a );<br />echo '变量b:';var_dump( $array_b );<br />echo '变量c:';var_dump( $array_c );<br />echo '变量d:';var_dump( $array_d );<br />
<br />变量a:<br />array (size=1)<br /> 0 => &string 'b' (length=1)<br />变量b:<br />array (size=1)<br /> 0 => &string 'b' (length=1)<br />变量c:<br />string 'b' (length=1)<br />变量d:<br />array (size=1)<br /> 0 => &string 'b' (length=1)<br />
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号