锟斤拷时锟斤拷使锟矫可憋拷锟斤拷锟斤拷锟斤拷呛芊锟斤拷锟侥★拷锟斤拷锟斤拷说锟斤拷一锟斤拷锟斤拷锟斤拷锟侥憋拷锟斤拷锟斤拷锟斤拷锟皆讹拷态锟斤拷锟斤拷锟矫猴拷使锟矫★拷一锟斤拷锟斤拷通锟侥憋拷锟斤拷通锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟矫o拷锟斤拷锟界:
<?php
$a = 'hello';
?>
一锟斤拷锟缴憋拷锟斤拷锟斤拷锟饺★拷锟揭伙拷锟斤拷锟酵拷锟斤拷锟斤拷锟街碉拷锟轿拷锟斤拷锟缴憋拷锟斤拷锟斤拷谋锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 hello 使锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷元锟斤拷锟脚o拷$锟斤拷锟皆后,就匡拷锟斤拷锟斤拷为一锟斤拷锟缴憋拷锟斤拷锟斤拷谋锟斤拷锟斤拷恕锟斤拷锟斤拷纾�
<?php
$$a = 'world';
?>
锟斤拷时锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟剿o拷$a 锟斤拷锟斤拷锟斤拷锟斤拷"hello"锟斤拷锟斤拷 $hello 锟斤拷锟斤拷锟斤拷锟斤拷"world"锟斤拷锟斤拷耍锟斤拷锟斤拷锟斤拷锟戒:
<?php
echo "$a ${$a}";
?>
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷全锟斤拷同锟侥斤拷锟斤拷锟�
<?php
echo "$a $hello";
?>
锟斤拷锟角讹拷锟斤拷锟斤拷锟斤拷锟�hello world锟斤拷
要锟斤拷锟缴憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷椋拷锟斤拷锟斤拷锟揭伙拷锟侥o拷锟斤拷锟斤拷傻锟斤拷锟斤拷狻o拷锟斤拷锟角碉拷写锟斤拷 $$a[1] 时锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷要知锟斤拷锟斤拷锟斤拷要 $a[1] 锟斤拷为一锟斤拷锟斤拷锟斤拷锟截o拷锟斤拷锟斤拷锟斤拷要 $$a 锟斤拷为一锟斤拷锟斤拷锟斤拷锟斤拷取锟斤拷锟矫憋拷锟斤拷锟斤拷锟斤拷锟斤拷为 [1] 锟斤拷值锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤法锟角o拷锟皆碉拷一锟斤拷锟斤拷锟斤拷锟� ${$a[1]}锟斤拷锟皆第讹拷锟斤拷锟斤拷锟斤拷锟� ${$a}[1]锟斤拷
锟斤拷锟斤拷锟斤拷锟揭诧拷锟斤拷锟酵拷锟斤拷杀锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷省锟斤拷杀锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷诟玫锟斤拷锟斤拷锟斤拷锟斤拷姆锟轿э拷诒锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷纾拷锟斤拷锟� $foo->$bar 锟斤拷锟绞斤拷锟斤拷锟斤拷锟节憋拷锟截凤拷围锟斤拷锟斤拷锟斤拷 $bar 锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷锟斤拷 $foo 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 $bar 锟斤拷锟斤拷锟介单元时也锟斤拷一锟斤拷锟斤拷
也锟斤拷使锟矫伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟界。锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷位锟斤拷锟斤拷锟斤拷锟叫o拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫讹拷锟斤拷锟斤拷只锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷蟹欠锟斤拷址锟绞憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟� json_decode() 锟斤拷 SimpleXML锟斤拷锟斤拷
Example #1 锟缴憋拷锟斤拷锟斤拷示锟斤拷
<?php
class foo {
var $bar = 'I am bar.';
var $arr = array('I am A.', 'I am B.', 'I am C.');
var $r = 'I am r.';
}
$foo = new foo();
$bar = 'bar';
$baz = array('foo', 'bar', 'baz', 'quux');
echo $foo->$bar . "\n";
echo $foo->$baz[1] . "\n";
$start = 'b';
$end = 'ar';
echo $foo->{$start . $end} . "\n";
$arr = 'arr';
echo $foo->$arr[1] . "\n";
echo $foo->{$arr}[1] . "\n";
?>
锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�
注锟解,锟斤拷 PHP 锟侥猴拷锟斤拷锟斤拷锟斤拷姆锟斤拷锟斤拷校锟�锟斤拷全锟街憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟缴憋拷锟斤拷锟斤拷锟�$this 锟斤拷锟斤拷也锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷鼙锟斤拷锟教拷锟斤拷谩锟�