PHP Language Constants

PHP provides a large number of predefined constants to any script which it runs. These constants change depending on where they are used. These special constants are case-insensitive.

images/articles/php/php-language-constants.jpg

__LINE__

LINE gives the current line number of the file.

__FILE__

FILE gives the full path and file name of the file with symlinks resolved. If used inside an include, the name of the included file is returned.

__DIR__

DIR gives the directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory.

__FUNCTION__

FUNCTION gives the function name.

__CLASS__

CLASS gives the class name.