PHP浼犲€煎拰浼犲紩鐢ㄣ€佷紶鍦板潃鐨勫尯鍒槸浠€涔堬紵_PHP鏁欑▼ | 甯涔嬪
鏄妸瀹炲弬鐨勫€艰祴鍊肩粰琛屽弬
閭d箞瀵硅鍙傜殑淇敼锛屼笉浼氬奖鍝嶅疄鍙傜殑鍊?/p>
浼犲湴鍧€
鏄紶鍊肩殑涓€绉嶇壒娈婃柟寮忥紝鍙槸浠栦紶閫掔殑鏄湴鍧€锛屼笉鏄櫘閫氱殑濡俰nt
閭d箞浼犲湴鍧€浠ュ悗锛屽疄鍙傚拰琛屽弬閮芥寚鍚戝悓涓€涓璞?/p>
浼犲紩鐢?/p>
鐪熸鐨勪互鍦板潃鐨勬柟寮忎紶閫掑弬鏁?/p>
浼犻€掍互鍚庯紝琛屽弬鍜屽疄鍙傞兘鏄悓涓€涓璞★紝鍙槸浠栦滑鍚嶅瓧涓嶅悓鑰屽凡
瀵硅鍙傜殑淇敼灏嗗奖鍝嶅疄鍙傜殑鍊?/p>
-----------------------------------------------------------------------------------
瑙夊緱浠庡嚱鏁拌皟鐢ㄧ殑瑙掑害鐞嗚В姣旇緝濂?/p>
浼犲€硷細
鍑芥暟鍙傛暟鍘嬫爤鐨勬槸鍙傛暟鐨勫壇鏈€?/p>
浠讳綍鐨勪慨鏀规槸鍦ㄥ壇鏈笂浣滅敤锛屾病鏈変綔鐢ㄥ湪鍘熸潵鐨勫彉閲忎笂銆?/p>
浼犳寚閽堬細
鍘嬫爤鐨勬槸鎸囬拡鍙橀噺鐨勫壇鏈€?/p>
褰撲綘瀵规寚閽堣В鎸囬拡鎿嶄綔鏃讹紝鍏跺€兼槸鎸囧悜鍘熸潵鐨勯偅涓彉閲忥紝鎵€浠ュ鍘熸潵鍙橀噺鎿嶄綔銆?/p>
浼犲紩鐢細
鍘嬫爤鐨勬槸寮曠敤鐨勫壇鏈€傜敱浜庡紩鐢ㄦ槸鎸囧悜鏌愪釜鍙橀噺鐨勶紝瀵瑰紩鐢ㄧ殑鎿嶄綔鍏跺疄灏辨槸瀵逛粬鎸囧悜鐨勫彉閲忕殑鎿嶄綔銆傦紙浣滅敤鍜屼紶鎸囬拡涓€鏍凤紝鍙槸寮曠敤灏戜簡瑙f寚閽堢殑鑽夌焊锛?nbsp;
-----------------------------------------------------------------------------------
鍑芥暟鍙傛暟浼犻€掓満鍒剁殑鍩烘湰鐞嗚
銆€銆€鍑芥暟鍙傛暟浼犻€掓満鍒堕棶棰樺湪鏈川涓婃槸璋冪敤鍑芥暟锛堣繃绋嬶級鍜岃璋冪敤鍑芥暟锛堣繃绋嬶級鍦ㄨ皟鐢ㄥ彂鐢熸椂杩涜閫氫俊鐨勬柟娉曢棶棰樸€傚熀鏈殑鍙傛暟浼犻€掓満鍒舵湁涓ょ锛氬€间紶閫掑拰寮曠敤浼犻€掋€備互涓嬭璁虹О璋冪敤鍏朵粬鍑芥暟鐨勫嚱鏁颁负涓昏皟鍑芥暟锛岃璋冪敤鐨勫嚱鏁颁负琚皟鍑芥暟銆?/p>
銆€銆€鍊间紶閫掞紙passl-by-value锛夎繃绋嬩腑锛岃璋冨嚱鏁扮殑褰㈠紡鍙傛暟浣滀负琚皟鍑芥暟鐨勫眬閮ㄥ彉閲忓鐞嗭紝鍗冲湪鍫嗘爤涓紑杈熶簡鍐呭瓨绌洪棿浠ュ瓨鏀剧敱涓昏皟鍑芥暟鏀捐繘鏉ョ殑瀹炲弬鐨勫€硷紝浠庤€屾垚涓轰簡瀹炲弬鐨勪竴涓壇鏈€傚€间紶閫掔殑鐗圭偣鏄璋冨嚱鏁板褰㈠紡鍙傛暟鐨勪换浣曟搷浣滈兘鏄綔涓哄眬閮ㄥ彉閲忚繘琛岋紝涓嶄細褰卞搷涓昏皟鍑芥暟鐨勫疄鍙傚彉閲忕殑鍊笺€?/p>
銆€銆€寮曠敤浼犻€?pass-by-reference)杩囩▼涓紝琚皟鍑芥暟鐨勫舰寮忓弬鏁拌櫧鐒朵篃浣滀负灞€閮ㄥ彉閲忓湪鍫嗘爤涓紑杈熶簡鍐呭瓨绌洪棿锛屼絾鏄繖鏃跺瓨鏀剧殑鏄敱涓昏皟鍑芥暟鏀捐繘鏉ョ殑瀹炲弬鍙橀噺鐨勫湴鍧€銆傝璋冨嚱鏁板褰㈠弬鐨勪换浣曟搷浣滈兘琚鐞嗘垚闂存帴瀵诲潃锛屽嵆閫氳繃鍫嗘爤涓瓨鏀剧殑鍦板潃璁块棶涓昏皟鍑芥暟涓殑瀹炲弬鍙橀噺銆傛鍥犱负濡傛锛岃璋冨嚱鏁板褰㈠弬鍋氱殑浠讳綍鎿嶄綔閮藉奖鍝嶄簡涓昏皟鍑芥暟涓殑
瀹炲弬鍙橀噺銆?/p>
-----------------------------------------------------------------------------------
浠呰璁轰竴涓嬪€间紶閫掑拰寮曠敤锛?/p>
鎵€璋撳€间紶閫掞紝灏辨槸璇翠粎灏嗗璞$殑鍊间紶閫掔粰鐩爣瀵硅薄锛屽氨鐩稿綋浜巆opy锛涚郴缁熷皢涓虹洰鏍囧璞¢噸鏂板紑杈熶竴涓畬鍏ㄧ浉鍚岀殑鍐呭瓨绌洪棿銆?/p>
鎵€璋撳紩鐢紝灏辨槸璇村皢瀵硅薄鍦ㄥ唴瀛樹腑鐨勫湴鍧€浼犻€掔粰鐩爣瀵硅薄锛屽氨鐩稿綋浜庝娇鐩爣瀵硅薄鍜屽師濮嬪璞″搴斿悓涓€涓唴瀛樺瓨鍌ㄧ┖闂淬€傛鏃讹紝濡傛灉瀵圭洰鏍囧璞¤繘琛屼慨鏀癸紝鍐呭瓨涓殑鏁版嵁涔熶細鏀瑰彉銆?/p>
$a = 'c';
$b = &$a; //琛ㄧず$b 鍜?a 寮曠敤浜嗗悓涓€涓彉閲?/p>
$a = 'abc'; //杩欓噷閲嶇疆浜?a
echo $b; //灏嗚緭鍑篴bc
unset($a);//鍙栨秷寮曠敤
echo $b;//杩欓噷浠嶈緭鍑篴bc
$a = 'abcd';
echo $b;//鍥犱负宸茬粡鍙栨秷寮曠敤 杩欓噷浠嶈緭鍑篴bc
上一篇: yaf namespace的使用
下一篇: yaf使用入门