PHP鎺у埗缁撴瀯涔媟equire

鍐呭鎽樿
require() 璇彞鍖呭惈骞惰繍琛屾寚瀹氭枃浠躲俽equire() 璇彞鍖呭惈骞惰繍琛屾寚瀹氭枃浠躲傛湁鍏冲寘鎷浣曞伐浣滅殑璇︾粏淇℃伅瑙 include() 鐨勬枃妗c
鏂囩珷姝f枃
require()
require() 璇彞鍖呭惈骞惰繍琛屾寚瀹氭枃浠躲

require() 璇彞鍖呭惈骞惰繍琛屾寚瀹氭枃浠躲傛湁鍏冲寘鎷浣曞伐浣滅殑璇︾粏淇℃伅瑙 include() 鐨勬枃妗c

require() 鍜 include() 鍑犱箮瀹屽叏涓鏍凤紝闄や簡澶勭悊澶辫触鐨勬柟寮忎笉鍚屼箣澶栥俰nclude() 浜х敓涓涓猈arning鑰 require() 鍒欏鑷翠竴涓 Fatal Error銆傛崲鍙ヨ瘽璇达紝濡傛灉鎯冲湪涓㈠け鏂囦欢鏃跺仠姝㈠鐞嗛〉闈紝閭e氨鍒姽璞簡锛岀敤 require() 鍚с俰nclude() 灏变笉鏄繖鏍凤紝鑴氭湰浼氱户缁繍琛屻傚悓鏃朵篃瑕佺‘璁よ缃簡鍚堥傜殑include_path銆


Example #1 鍩烘湰鐨 require() 渚嬪瓙

<?php

require 'prepend.php';

require $somefile;

require ('somefile.txt');

?>
鏇村渚嬪瓙鍙傝 include() 鏂囨。銆

Note: 鍦 PHP 4.0.2 涔嬪墠閫傜敤浠ヤ笅瑙勫垯锛歳equire() 鎬绘槸浼氬皾璇曡鍙栫洰鏍囨枃浠讹紝鍗充娇瀹冩墍鍦ㄧ殑琛屾牴鏈氨涓嶄細鎵ц銆傛潯浠惰鍙ヤ笉浼氬奖鍝 require()銆備笉杩囧鏋 require() 鎵鍦ㄧ殑琛屾病鏈夋墽琛岋紝鍒欑洰鏍囨枃浠朵腑鐨勪唬鐮佷篃涓嶄細鎵ц銆傚悓鏍凤紝寰幆缁撴瀯涔熶笉褰卞搷 require() 鐨勮涓恒傚敖绠$洰鏍囨枃浠朵腑鍖呭惈鐨勪唬鐮佷粛鐒舵槸寰幆鐨勪富浣擄紝浣 require() 鏈韩鍙細杩愯涓娆°

Note: 鍥犱负鏄竴涓瑷鏋勯犲櫒鑰屼笉鏄竴涓嚱鏁帮紝涓嶈兘琚 鍙彉鍑芥暟 璋冪敤銆

Warning
Windows 鐗堟湰鐨 PHP 鍦 4.3.0 鐗堜箣鍓嶄笉鏀寔閫氳繃姝ゅ嚱鏁拌闂繙绋嬫枃浠讹紝鍗充娇宸茬粡鍚敤 allow_url_fopen.

鍙傝 include()锛宺equire_once()锛宨nclude_once()锛実et_included_files()锛宔val()锛宖ile()锛宺eadfile()锛寁irtual() 鍜 include_path銆

浠ヤ笂灏辨槸PHP鎺у埗缁撴瀯涔媟equire鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒



鏈枃URL锛http://www.odweb.cn/news_show.html?id=86