比如:程序根目录在:E:\wamp\www 中
1. __FILE__ 当前文件的绝对路径
如果在index.php中调用 则返回 E:\wamp\www\index.php
下面再看一下 程序根目录的目录结构
如果在 c_system_base.php中调用__FILE__ 则返回:
E:\wamp\www\zb_system\function\c_system_base.php
2.dirname 返回当前目录的上级目录 或当前文件所在的目录 (结尾不带/)
一般跟__FILE__联合使用
如果在 c_system_base.php中调用dirname(__FILE__) 则返回
E:\wamp\www\zb_system\function (文说件返回所在目录)
如果调用 dirname(dirname(__FILE__)) 则返回
E:\wamp\www\zb_system (目录返回上级目录)
realpath() 方法 返回当前文件的绝对路径 或 相对根目录的路径
如果在 c_system_base.php中调用realpath(__FILE__) 则返回
E:\wamp\www\zb_system\function\c_system_base.php
realpath('/') 返回磁盘根目录 E:\
realpath('./') 返回根目录 E:\wamp\www
realpath('../') 返回相对程序根目录的上级目录
也可以和dirname配合使用 一般还会加上几个相对路径../ (前面要加/ 即:/../)
realpath(dirname(__FILE__)) 返回 E:\wamp\www\zb_system\function
realpath(dirname(__FILE__).'/../') 返回 E:\wamp\www\zb_system
realpath(dirname(__FILE__).'/../../') 返回 E:\wamp\www

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Notepad++7.3.1
Easy-to-use and free code editor

Zend Studio 13.0.1
Powerful PHP integrated development environment
