Research & Documentation 02 Php.net

__LINE__

The __LINE__ magic constant displays the current line number of the file.

Demo:

This is line #17

__FILE__

This magic constant can be used to display the full path of the current file.

Demo:

The full path of this file is: /var/www/vhosts/mpino.bitweb1.nwtc.edu/httpdocs/php/research-documentation/02-php.net.php

__DIR__

The __DIR__ will display the current directory of this file. If it was used in an include file, it would return the directory of that file.

Demo:

Current file directory /var/www/vhosts/mpino.bitweb1.nwtc.edu/httpdocs/php/research-documentation/n

__FUNCTION__

The __FUNCTION__ magic constant returns the name of the function being called.

Demo:

The Magic Constant name is: magicConstantFunction

Resources

  1. PHP Magic Constants
  2. TutorialRepublic - Magic Constants
  3. PHP Tutorials
  4. GeeksforGeeks | PHP | Magic Constants