首页 > Web开发 > 详细

16)PHP, set_include_path

时间:2017-08-08 18:28:26      阅读:257      评论:0      收藏:0      [点我收藏+]

代码展示:

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn">
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
 5     <title>网页标题</title>
 6     <meta name="keywords" content="关键字列表" />
 7     <meta name="description" content="网页描述" />
 8     <link rel="stylesheet" type="text/css" href="" />
 9     <style type="text/css"></style>
10     <script type="text/javascript"></script>
11 </head>
12 <body>
13 <?php
14     //设定配置文件中的include_path的值——代码中的设定只对当前代码有效。
15     //而且这里的设定,无需重启apache
16     set_include_path(D:\00-Code\PhpStorm\Demo\demo01);
17     
18     //更常见的做法:
19     $path = get_include_path();    //先获取系统的include_path值
20     $path_new = $path . PATH_SEPARATOR ."C:/";
21     //PATH_SEPARATOR: 是系统常量,代表目录分割符:
22     //        unix系列中,是“:”
23     //        window系列中,是“;”
24     set_include_path($path_new);    //再来设定“自己”想要加入的paht路径
25     //这样就不会破坏(丢失)原有路径设定
26     
27     echo "<p>当前工作目录:" . getcwd() .</p>;    //getcwd()获得当前工作目录
28     
29     //相对路径:
30 //    include ‘c.php‘;
31     
32 ?>
33 </body>
34 </html>

结果展示:

当前工作目录:D:\00-Code\PhpStorm\Demo\demo01

16)PHP, set_include_path

原文:http://www.cnblogs.com/xiaoyoucai/p/7308147.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!