


PHP Get file path (flexible application __FILE__)_PHP tutorial
__FILE__ is the full path and file name of the returned file. If used in an include file, returns the include file name. As of PHP 4.0.2, __FILE__ always contains an absolute path, while versions before that sometimes contained a relative path. dirname(__FILE__), returns the partial path of the current file path, that is, removing the file name.
Demo code:
// Get the current path + file name of the file
echo __FILE__;
echo '
';
// Get the current path of the file
echo dirname(__FILE__);
echo '
';
/ / Get the upper-level directory path of the file
echo dirname(dirname(__FILE__));
?>
Run result:
D:wampwwwindex.php
D:wampwww
D:wamp
__FILE__ is very useful. It can get the current path of the file. It will not change even if it is included. It can be used as the absolute path of the website on the server, and other directories will be distributed based on this.

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
