php predeffined constants code example

Example: php predefined constants

<?php 
  
// EXAMPLE (a superglobal is a variable that is predefined within the environment)
echo "This is line " . __LINE__ . " of the [" . __FILE__ . "] file";
// OUTPUT: This is line 31 of the [C:/MadeUpFolder/MadeUpFile.php] file 

// Superglobals
/******************+***************************************************
| <<< VARIABLE >>> |<<< DESCRIPTION >>>
+******************+***************************************************
|   __FILE__       | The current line number of the file.
+------------------+---------------------------------------------------
|   __LINE__       | The full path and filename of the file
+------------------+---------------------------------------------------
|   __DIR__        | The directory of the file
+------------------+---------------------------------------------------
|   __FUNCTION__   | The function name
+------------------+---------------------------------------------------
|   __CLASS__      | The class name
+------------------+---------------------------------------------------
|   __METHOD__     | The class method name
+------------------+---------------------------------------------------
|   __NAMESPACE__  | The name of the current namespace (case-sensitive)
+------------------+---------------------------------------------------
*/

?>

Tags:

Php Example