指针问题 问一下,一个指针,带*号,和不带*咋个用的啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下是手册中关于PHP变量的指针的例子,理解一下. 注意其中几行加粗的,变量的变化.In response to the example by mdiricks. Extending the example given by mdiricks, the following code provides an explains the concept of re-referencing that is involved in making a call to function foo with the prototype foo(& var): <!-- C re-referenced --> <? $a = 'eh'; $b = & $a; // $b == 'eh' $c = & $b; // $c == 'eh' $d = 'meh'; echo "\$a = $a\n"; //$a = eh echo "\$b = $b\n"; //$b = eh echo "\$c = $c\n"; //$c = eh echo "\$d = $d\n"; //$d = meh $c = & $d ;// $c == 'meh' echo "\n"; echo "\$a = $a\n"; //$a = eh echo "\$b = $b\n"; //$b = eh echo "\$c = $c\n"; //$c = meh echo "\$d = $d\n"; //$d = meh ?> <!-- Value of c changed --> <? $a = 'eh'; $b = & $a;// $b == 'eh' $c = & $b;// $c == 'eh' $d = 'meh'; echo "\$a = $a\n"; //$a = eh echo "\$b = $b\n"; //$b = eh echo "\$c = $c\n"; //$c = eh echo "\$d = $d\n"; //$d = meh $c = 'meh' ;// $c == 'meh'. And also, $a = $b == 'meh' echo "\n"; echo "\$a = $a\n"; //$a = meh echo "\$b = $b\n"; //$b = meh echo "\$c = $c\n"; //$c = meh echo "\$d = $d\n"; //$d = meh ?> This results in the following o/p: <!-- C re-referenced --> $a = eh $b = eh $c = eh $d = meh $a = eh $b = eh $c = meh $d = meh <!-- Value of c changed --> $a = eh $b = eh $c = eh $d = meh $a = meh $b = meh $c = meh $d = meh *是地址引用...并不是指针...比如:$a = 'a';$b = &$a; //$b='a',$a='a'$a = 'b'; //$b='b',$a='a'如果使用引用的话,$b会随着引用的$a的值而变...而$a = 'a';$b = $a; //$b='a',$a='a'$a = 'b'; //$b='a',$a='b'而没使用地址引用的就不会变... $a = 'a';$b = &$a;$a = 'b'; //$b='b',$a='b'不好意思,手误...呵呵... 如何freetds 支持 ms sql 2005 如下代码怎么按钮显示在搜索况的下面 新闻提问关于PHP的问题 $string是字符串,那么$string.LF是什么意思 帮忙阿,急求《php高级编程》. 请问如何让tomcat支持php?谢! 怎样做网站?如何设计? 怎么让这里提示的是中文呢?有办法吗?新手见笑了 求助PHP preg_match() 正规则 php写好后台代码返回给前台jquery easyui 的datagrid中, kindeditor如何获取datagrid里面的值 iconv 编码转码问题 在PHP中如何判断数据的进制类型
注意其中几行加粗的,变量的变化.In response to the example by mdiricks. Extending the example given by mdiricks, the following code provides an explains the concept of re-referencing that is involved in making a call to function foo with the prototype foo(& var):
<!-- C re-referenced -->
<? $a = 'eh';
$b = & $a; // $b == 'eh'
$c = & $b; // $c == 'eh'
$d = 'meh'; echo "\$a = $a\n"; //$a = eh
echo "\$b = $b\n"; //$b = eh
echo "\$c = $c\n"; //$c = eh
echo "\$d = $d\n"; //$d = meh $c = & $d ;// $c == 'meh'
echo "\n"; echo "\$a = $a\n"; //$a = eh
echo "\$b = $b\n"; //$b = eh
echo "\$c = $c\n"; //$c = meh
echo "\$d = $d\n"; //$d = meh ?> <!-- Value of c changed -->
<? $a = 'eh';
$b = & $a;// $b == 'eh'
$c = & $b;// $c == 'eh'
$d = 'meh'; echo "\$a = $a\n"; //$a = eh
echo "\$b = $b\n"; //$b = eh
echo "\$c = $c\n"; //$c = eh
echo "\$d = $d\n"; //$d = meh $c = 'meh' ;// $c == 'meh'. And also, $a = $b == 'meh'
echo "\n"; echo "\$a = $a\n"; //$a = meh
echo "\$b = $b\n"; //$b = meh
echo "\$c = $c\n"; //$c = meh
echo "\$d = $d\n"; //$d = meh ?> This results in the following o/p:
<!-- C re-referenced -->
$a = eh
$b = eh
$c = eh
$d = meh $a = eh
$b = eh
$c = meh
$d = meh <!-- Value of c changed -->
$a = eh
$b = eh
$c = eh
$d = meh $a = meh
$b = meh
$c = meh
$d = meh
$a = 'a';
$b = &$a; //$b='a',$a='a'
$a = 'b'; //$b='b',$a='a'
如果使用引用的话,$b会随着引用的$a的值而变...而
$a = 'a';
$b = $a; //$b='a',$a='a'
$a = 'b'; //$b='a',$a='b'
而没使用地址引用的就不会变...
$b = &$a;
$a = 'b'; //$b='b',$a='b'不好意思,手误...呵呵...