Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

[ת£ÝÉîÈëÀí½âPHPÖ®require/include˳Ðò


×÷Õß: laruence(http://www.laruence.com
)
±¾ÎĵØÖ·: http://www.laruence.com/2010/05/04/1450.html
תÔØÇë×¢Ã÷³ö´¦
ÔÚ´óÐ͵ÄWebÏîÄ¿ÖÐ, include_pathÊÇÒ»¸öÄ£¿é»¯Éè¼ÆµÄ¸ù±¾Öеĸù±¾(µ±È»,ÏÖÔÚÒ²Óкܶà»ùÓÚautoloadµÄÉè¼Æ,
Õâ¸ö²»Ó°Ïì±¾ÎĵÄ̽ÌÖ), µ«ÊÇÕýÊÇÒòΪinclude_path, ¾­³£»áÈÃÎÒÃÇÓöµ½Ò»Ð©ÒòΪûÓÐÕÒµ½ÕýÈ·µÄÎļþ¶øµ¼ÖµĿ´ËÆ”¹îÒ씵ÄÎÊÌâ.
Ò²¾ÍÓÐÁËÈçϵÄÒÉÎÊ:
include_pathÊÇÔõôÆð×÷ÓõÄ?
Èç¹ûÓжà¸öinclude_path˳ÐòÊÇÔõôÑùµÄ?
ʲôÇé¿öÏÂinclude_path²»Æð×÷ÓÃ?
½ñÌì, ÎÒ¾ÍÈ«ÃæµÄ½éÉÜÏÂÕâ¸öÎÊÌâ, ÏÈ´ÓÒ»¸öÀý×Ó¿ªÊ¼°É.
ÈçϵÄĿ¼½á¹¹:
root
©À 1.php
©À 3.php
©¸ subdir
©À 2.php
©¸ 3.php
ÔÚ1.phpÖÐ:
<?php
ini_set
(
"include_path"
,
".:path_to_subdir"
);
require
(
"2.php"
);
?>
¶øÔÚ2.phpÖÐ:
<?php
require
(
"3.php"
);
?>
¶øÔÚrootĿ¼ÏµÄ3.php´òÓ¡³ö”root”, ÔÚsubdirĿ¼ÏµÄ3.php´òÓ¡³ö”subdir”;
ÏÖÔÚ, ÎÒµÄÎÊÌâÀ´ÁË:
1. µ±ÔÚrootĿ¼ÏÂÔËÐÐ1.php, »áµÃµ½Ê²Ã´Êä³ö?
2. ÔÚsubdirÏÂÔËÐÐÉÏÒ»¼¶Ä¿Â¼µÄ1.php, ÓлáµÃµ½Ê²Ã´Êä³ö?
3. µ±È¡Ïûinclude_pathÖеĵ±Ç°Ä¿Â¼path(Ò²¾ÍÊÇinclude_path=”path_to_subdir”), ÉÏÃæÁ©¸öÎÊÌâÓÖ»áÊÇʲôÊä³ö?
PHPÖеÄinclude_path
PHPÔÚÓöµ½require(_once)/include(_once)µÄÖ¸ÁîµÄʱºò, Ê×ÏÈ»á×öÈçϵÄÅжÏ:
Òª°üº¬µÄÎļþ·¾¶ÊǾø¶Ô·¾¶Ã´?
 Èç¹ûÊÇ, ÔòÖ±½Ó°üº¬, ²¢½áÊø.
 Èç¹û²»ÊÇ, ½øÈëÁíÍâµÄÂß¼­(¾­¹ý¶à´Îµ÷ÓÃ, ºêÕ¹¿ªºó½øÈë_php_stream_fopen_with_path)Ñ°ÕÒ´ËÎļþ
½ÓÏÂÀ´, ÔÚ_php_stream_fopen_with_pathÖÐ, »á×öÈçÏÂÅжÏ:
Òª°üº¬µÄÎļþ·¾¶ÊÇÏà¶Ô·¾¶Ã´(ÐÎÈç./file, ../dir/file, ÒÔÏÂÓÃ"Ŀ¼Ïà¶Ô·¾¶´úÌæ")?
 Èç¹ûÊÇ, ÔòÌø¹ýinclude_pathµÄ×÷ÓÃÂß¼­, Ö±½Ó½âÎöÏà¶Ô·¾¶(Ëæºóµ¥¶À½éÉÜ).
»á¸ù¾Ýinclude_path,ºÍµ±Ç°Ö´ÐÐÎļþµÄpath×é³ÉÒ»¸ö´ýÑ¡µÄĿ¼Áбí, ±ÈÈç¶ÔÓÚÎÄÕÂÇ°ÃæµÄÀý×ÓÀ´Ëµ, »áÐγÉÒ»¸öÈçϵĴýÑ¡Áбí
".:path_to_subdir:current_script_dir"
È»ºó, ÒÀ´Î´Ó´ýÑ¡ÁбíÍ·²¿¿ªÊ¼, ¸ù¾ÝDEFAULT_DIR_SEPARATOR(±¾ÎĵĻ·¾³ÊÇ”:”)È¡³ö´ýÑ¡ÁбíÖеÄÒ»¸ö·¾¶, È»ºó°ÑÒª°üº¬µÄÎļþÃû¸½¼ÓÔÚÕâ¸ö·¾¶ºóÃæ, ½øÐг¢ÊÔ. Èç¹û³É¹¦°üº¬, Ôò·µ»Ø, ·ñÔò¼ÌÐøÏÂ


Ïà¹ØÎĵµ£º

ÖØÒªµÄPHP³¬¼¶È«¾Ö±äÁ¿×ܽá




ÖØÒªµÄPHP³¬¼¶È«¾Ö±äÁ¿×ܽá

2008-07-14 16:53:03
¡¡±êÇ©£ºÈ«¾Ö±äÁ¿
¡¡¡¡¡¡[ÍÆË͵½¼¼ÊõȦ
]
        PHPÓÐ9¸öÔ¤¶¨Òå±äÁ¿Êý×飬·Ö±ð×ܽáÈçÏ£º
 
1¡¢$_SERVER
       
$_SERVER³¬¼¶È«¾Ö±äÁ¿°üº¬ÓÉweb·þÎñÆ÷´´½¨µÄÐÅÏ¢ ......

phpÉú³ÉwordÎĵµ,²¢¿ÉÒÔÏÂÔØ

<?php
if($_POST['str'])
{
header('Content-type: application/doc');
header('Content-Disposition: attachment; filename="downloaded.doc"');
echo iconv("UTF-8","GB2312",$_POST['str']);
}
?>
<a href="javascript:void(0)" onclick="downword()">ÏÂÔØ</a>
<div id="word" style="dis ......

˼¿¼ PHP+MYSQLµÄOAΪºÎûÓÐJavaµÄֵǮ?


ÏÖÔÚÊг¡ÉϵÄoa»ù±¾ÉϿɹé½áΪÁ½´óÕóÓª£¬¼´phpÕóÓªºÍjavaÕóÓª¡£µ«¶Ô½Ó´¥oa²»¾ÃµÄÓû§À´Ëµ£¬¿´µ½µÄÍùÍùÖ»ÊÇËüÃǵıíÏֻ࣬ÊÇÃ÷ÏԵļ۸ñ²îÒ죬ȴºÜÄÑ¿´³öËüÃÇÖ®¼äµÄʵ¼Ê²îÒì¡£Æäʵ£¬ PHP + MYSQL ²»ÖµÇ®²»½ö½ö¾ÖÏÞÓÚoaÈí¼þ£¬¶øÊÇÕûÌåÉÏPHP + MYSQL¿ª·¢µÄÈí¼þ¶¼²»Èçjava¿ª·¢µÄÈí¼þֵǮ¡£ÎªÊ²Ã´PHP + MYSQL µÄOAΪʲô²»ÖµÇ®Ä ......

PHP·ÖÒ³´úÂë

Í·²¿µ÷ÓÃ
 <?
require('conn.php');
$sql1="select id from news";
$query1=mysql_query($sql1,$conn);
$sun_num=mysql_num_rows($query1);
$gs=20;
$page_num=ceil($sun_num/$gs);
include("../subpage.php");
//´«¹ýÀ´µÄÒ³Êý²ÎÊý
$PB_page=$_GET['PB_page'];
if ($PB_page==1 or empty($PB_page)){
$ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ