Search notes:

PHP code snippets: __FILE__, __LINE__ and __DIR__

__FILE__ expands to name of the file where this identifier occurs, __DIR__ to its directory name and __LINE__ to the line number.
<html>
<head><title>__LINE__ __FILE__ __DIR__</title></head>
  <style type="text/css">
    tr {vertical-align: top}
    td:nth-child(2) {width:40%} /* Path should not be broken on two lines except on small monitors. */
  </style>
<body>

  <table border=1>
    <tr><td>__LINE__</td><td><?php echo __LINE__ ?></td><td>&nbsp;</td></tr>
    <tr><td>__FILE__</td><td><?php echo __FILE__ ?></td><td>Compare with <a href='_SERVER.html'><code>$_SERVER['SCRIPT_FILENAME']</code></a>. Especially windows
                                                            uses backslashes in <code>__FILE__</code> while <code>$_SERVER['SCRIPT_FILENAME']</code> uses 
                                                            forward slashes.</td></tr>
    <tr><td>__DIR__ </td><td><?php echo __DIR__  ?></td><td>&nbsp;</td></tr>
  </table>

</body>
</html>
Github repository about-php, path: /__LINE__FILE__DIR__.html

See also

The predefined preprocessor macros __FUNCTION__, __FILE__ and __LINE__ in C and C++.
$_SERVER['SCRIPT_FILENAME'

Index