php——includeÓï¾ä
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/2010/02/02/1-9/
PHPÖÐIncludeÓï¾äÔÚÓ÷¨ÉϺÍrequireÓï¾ä»ù±¾Ïàͬ£¬µ«ÊÇËûÃÇ»¹´æÔÚÁ½µã²îÒ죺
»úÖƲ»Í¬
RequireÓï¾äÔÚ½øÐÐÎļþ°üº¬Ê±£¬²»¹ÜÕâÌõrequireÓï¾äÊÇ·ñ±»ÔËÐУ¬¶¼»á½«±»°üº¬´úÂëÖеÄÎļþ°üº¬½øÀ´¡£
IncludeÓï¾äÔÚ½øÐÐÎļþ°üº¬Ê±£¬Èç¹ûÕâÌõincludeÓï¾äûÓб»ÔËÐУ¬Ôò²»»á½«±»°üº¬´úÂëÖеÄÎļþ°üº¬½øÀ´¡£
ÈçÒÔÏ´úÂ룺
<?php
¡¡$a = 1;
¡¡if($a ==2) //Èç¹ûµÈÓÚ2£¬Ôòµ÷ÓÃ
¡¡require(“include.inc”);
?>
Õâ¸öÀý×ÓÖÐÌõ¼þûÓÐÂú×㣬ËùÒÔµ÷ÓÃÓï¾äûÓÐÖ´ÐУ¬µ«ÊÇinclude.incÈÔÈ»±»°üº¬½øÀ´£¬Ö»ÊÇûÓб»µ÷Óá£
¡¡<?php
¡¡¡¡$a = 1;
¡¡¡¡if($a ==2)
¡¡¡¡include(“include.inc”);
¡¡?>
Õâ¸öPHP´úÂëÖУ¬³ÌÐòûÓаÑinclude.incÖдúÂë°üº¬½øÀ´¡£
PHPÖÐÎļþ²»´æÔÚʱµÄ´íÎó´¦Àí·½Ê½²»Í¬
Èç¹ûÎļþÎÞ·¨ÕÒµ½£¬requireºÍincludeµÄ´íÎóÌáʾÊDz»Í¬µÄ¡£
RequireÓï¾ä»áÅ׳öÒ»¸öÖÂÃü´íÎó²¢ÖÐÖ¹½Å±¾µÄÔËÐС£È磺
¡¡<?php
¡¡¡¡require(“inc1.inc”); //inc1inc²»´æÔÚ
¡¡¡¡echo “This is a test!”;
¡¡?>
ÔËÐнá¹ûÈçÏ£º
Warning: require(inc1.inc) [function.require]: failed to open stream: No such file or directory in E:\xampp\xampp\htdocs\2.2.test6.php on line 2
Fatal error: require() [function.require]: Failed opening required ‘inc1.inc’ (include_path=’.;E:\xampp\xampp\php\pear\’) in E:\xampp\xampp\htdocs\2.2.test6.php on line 2
·ÖÎö£º¿ÉÒÔ¿´µ½£¬´íÎóÀàÐÍΪFatal error£¬²¢ÇÒ´úÂëÔÚrequire´¦ÖÐÖ¹ÁË¡£
IncludeÓï¾äÔò»áÅ׳ö¾¯¸æÐÅÏ¢£¬È磺
¡¡<?php
¡¡¡¡include(“inc1.inc”);
¡¡¡¡echo “This is a test!”;
¡¡?>
½á¹ûÈçÏ£º
Warning: include(inc1.inc) [function.include]: failed to open stream: No such file or directory in E:\xampp\xampp\htdocs\2.2.test7.php on line 2
Warning: include() [function.include]: Failed opening ‘inc1.inc’ for inclusion (include_path=’.;E:\xampp\xampp\php\pear\’) in E:\xampp\xampp\htdocs
Ïà¹ØÎĵµ£º
<?php
/**
* »ñȡͼÏóÐÅÏ¢µÄº¯Êý
*
* Ò»¸öÈ«Ãæ»ñȡͼÏóÐÅÏ¢µÄº¯Êý
*
* @access public
* @param string $img ͼƬ·¾¶
* @return array
*/
function GetImageInfoVal($ImageInfo,$val_arr) {
$InfoVal = "δ֪";
foreach($val_arr as $name=>$val) {
  ......
1 ¿ªÊ¼Ð´PHP³ÌÐò
¸úѧC/C++¡¢javaÒ»Ñù£¬ÎÒÃÇÏÈ´Óhello world¿ªÊ¼£º
PHP µÄ½Å±¾¿éÒÔ <?php ¿ªÊ¼£¬ÒÔ ?> ½áÊø¡£Äú¿ÉÒÔ°Ñ PHP µÄ½Å±¾¿é·ÅÖÃÔÚhtmlÎĵµÖеÄÈκÎλÖᣵ±È»£¬ÔÚÖ§³Ö¼òдµÄ·þÎñÆ÷ÉÏ£¬Äú¿ÉÒÔʹÓà <? ºÍ ?> À´¿ªÊ¼ºÍ½áÊø½Å±¾¿é¡£²»¹ý£¬ÎªÁË´ïµ½×îºÃµÄ¼æÈÝÐÔ£¬ÎÒÃÇÍƼöÄúʹÓñê×¼ÐÎʽ£¨ <?php£© £¬¶ ......
±íµ¥ºÍÓû§ÊäÈë
PHP ±íµ¥´¦Àí
±íµ¥ÊµÀý£º
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html> ......
PHP
Îļþ´¦Àí
fopen()
º¯ÊýÓÃÓÚÔÚ
PHP
Öдò¿ªÎļþ¡£
´ò¿ªÎļþ
fopen()
º¯ÊýÓÃÓÚÔÚ
PHP
Öдò¿ªÎļþ¡£
´Ëº¯ÊýµÄµÚÒ»¸ö²ÎÊýº¬ÓÐÒª´ò¿ªµÄÎļþµÄÃû³Æ£¬µÚ¶þ¸ö²ÎÊý¹æ¶¨ÁËʹÓÃÄÄÖÖģʽÀ´´ò¿ªÎļþ£º
<html>
<body>
<?php
$file=fopen("welcome.txt","r");
?>
......
Ç°ÑÔ
¡¡¡¡
¡¡¡¡·Ï»°²»¶à˵£¬WebServiceÕâ¸öÈÈ°¡£¬PHPÕâ¸ö»ð°¡£¬ÏëÓÃPHP¿ª·¢WebServiceÊÇÀíËùµ±È»µÄÊ¡£Ê²Ã´£¿²»¶®WebService£¿Ã»Ê£¬°Ù¶ÈһϾÍÖªµÀÁË¡£°¡£¿¿´²»¶®£¿²»¶®Ò²Ã»¹Øϵ£¬Ö±½Ó¿´´óÉÙүдµÄ°É£º£©
¡¡¡¡´óÉÙÒ¯ÊǸö¼¤½ø·Ö×Ó£¬Ï²»¶Ö±½ÓÄôúÂë˵Ê£¬²»¹ýÔÚ°Ñ¿ÉÁ¯µÄ¶ÁÕßŪµÃһͷÎíˮ֮ǰ£¬»¹ÊÇÏÈ´óÖÂ˵һϱ¾ÎĵÄÄ¿ ......