Maison >développement back-end >tutoriel php >关于引用, 这种情况哪位高手能解释下
关于引用, 这种情况谁能解释下
代码段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 />