PHP provides a large number of predefined constants to any script which it runs.
However, there are nine "magical" constants that change depending on where they are used. These are called Magic Constants. They usually start and end with double underscores (__).
Here are the most widely used magic constants in professional PHP development:
__LINE__: The current line number of the file.__FILE__: The full path and filename of the file. If used inside an include, the name of the included file is returned.__DIR__: The directory of the file. This is equivalent to dirname(__FILE__).__FUNCTION__: The function name.__CLASS__: The class name. Includes the namespace it was declared in.__METHOD__: The class method name.__NAMESPACE__: The name of the current namespace.Magic constants are incredibly useful for debugging or dynamically including files based on relative folder paths.
// Includes a file safely using absolute paths require_once __DIR__ . '/includes/header.php';