鏈夋椂鍊欎娇鐢ㄥ彲鍙樺彉閲忓悕鏄緢鏂逛究鐨勩傚氨鏄锛屼竴涓彉閲忕殑鍙橀噺鍚嶅彲浠ュ姩鎬佺殑璁剧疆鍜屼娇鐢ㄣ備竴涓櫘閫氱殑鍙橀噺閫氳繃澹版槑鏉ヨ缃
鏈夋椂鍊欎娇鐢ㄥ彲鍙樺彉閲忓悕鏄緢鏂逛究鐨勩傚氨鏄锛屼竴涓彉閲忕殑鍙橀噺鍚嶅彲浠ュ姩鎬佺殑璁剧疆鍜屼娇鐢ㄣ備竴涓櫘閫氱殑鍙橀噺閫氳繃澹版槑鏉ヨ缃紝渚嬪锛
<?php
$a = 'hello';
?>
涓涓彲鍙樺彉閲忚幏鍙栦簡涓涓櫘閫氬彉閲忕殑鍊间綔涓鸿繖涓彲鍙樺彉閲忕殑鍙橀噺鍚嶃傚湪涓婇潰鐨勪緥瀛愪腑 hello 浣跨敤浜嗕袱涓編鍏冪鍙凤紙$锛変互鍚庯紝灏卞彲浠ヤ綔涓轰竴涓彲鍙樺彉閲忕殑鍙橀噺浜嗐備緥濡傦細
<?php
$$a = 'world';
?>
杩欐椂锛屼袱涓彉閲忛兘琚畾涔変簡锛$a 鐨勫唴瀹规槸鈥渉ello鈥濆苟涓 $hello 鐨勫唴瀹规槸鈥渨orld鈥濄傚洜姝わ紝鍙互琛ㄨ堪涓猴細
<?php
echo "$a ${$a}";
?>
浠ヤ笅鍐欐硶鏇村噯纭苟涓斾細杈撳嚭鍚屾牱鐨勭粨鏋滐細
<?php
echo "$a $hello";
?>
瀹冧滑閮戒細杈撳嚭锛歨ello world銆
瑕佸皢鍙彉鍙橀噺鐢ㄤ簬鏁扮粍锛屽繀椤昏В鍐充竴涓ā妫变袱鍙殑闂銆傝繖灏辨槸褰撳啓涓 $$a[1] 鏃讹紝瑙f瀽鍣ㄩ渶瑕佺煡閬撴槸鎯宠 $a[1] 浣滀负涓涓彉閲忓憿锛岃繕鏄兂瑕 $$a 浣滀负涓涓彉閲忓苟鍙栧嚭璇ュ彉閲忎腑绱㈠紩涓 [1] 鐨勫笺傝В鍐虫闂鐨勮娉曟槸锛屽绗竴绉嶆儏鍐电敤 ${$a[1]}锛屽绗簩绉嶆儏鍐电敤 ${$a}[1]銆
Warning
娉ㄦ剰锛屽湪 PHP 鐨勫嚱鏁板拰绫荤殑鏂规硶涓紝瓒呭叏灞鍙橀噺涓嶈兘鐢ㄤ綔鍙彉鍙橀噺銆
浠ヤ笂灏辨槸PHP鍙橀噺涓殑鍙彉鍙橀噺浠嬬粛鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒