PHP 中dirname(_file_)讲解
2007-03-18 00:00
459 查看
通常在配置文件路径的时候用dirname(__FILE__)是非常有效的方法,但是因为__FILE__的路径是当前代码所在文件(而不是url所在文件)完整路径,所以定义配置文件通常要放在根目录下定义网站的根地址,但是下面的方法可以解决配置文件的存放问题。
dirname(dirname(__FILE__)); /*
假设__FILE__为 /home/web/config/config.php
上面的方法输出为 /home/web
*/
dirname(dirname(__FILE__));得到的是文件上一层目录名
dirname(__FILE__);得到的是文件所在层目录名
dirname(dirname(__FILE__)); /*
假设__FILE__为 /home/web/config/config.php
上面的方法输出为 /home/web
*/
dirname(dirname(__FILE__));得到的是文件上一层目录名
dirname(__FILE__);得到的是文件所在层目录名
相关文章推荐
- PHP 中dirname(_file_)讲解
- PHP 中dirname(_file_)讲解
- PHP带头大哥讲解几种综合PHP网络服务器系统的选择!
- php中的move_uploaded_file
- php中的 file_get_contents(‘php://input’)用法
- PHP下通过file_get_contents的代理使用方法
- The index.php file (public / index.php)
- PHP使用之move_uploaded_file() 函数
- php中file_get_contents与curl性能比较分析
- PHP 获取 文件file_a相对于file_b的相对路径
- file_get_contents("php://input")
- php.h No such file or directory
- php生成毫秒时间戳的实例讲解
- file_get_contents("php://input") php://input 输入流
- php字符集转码 (兼转载一篇讲解字…
- PHP简单工厂模式(simple factory)趣味讲解
- php的网络编程(socket、curl、file_get_contents)三种方式。
- PHP下通过file_get_contents\curl的方法实现获取远程网页内容(别忘了还有PhpRPC)
- php中foreach()函数与Array数组经典案例讲解
- PHP 常量 dirname(__file__) 学习