__FUNCTION__ – The function name. In this tutorial you will learn how to work with PHP magic constants. PHP Constants are created using define() function. PHP has large number of predefined constants. What is Magic Constants.

You can get the name of the current PHP file (with the absolute path) using the __FILE__ magic constant. I've noticed some projects like to store constants in their own file, i.e constants used globally and in the main program loop might clutter the main file so perhaps they look to place them elsewhere and then reference/import file/class. This HOWTO will present the seven most important, most practical and most useful PHP Magic Constants. Current file. __FILE__ – The full path and filename of the file. PHP has constant values for file upload errors which lets you specify the exact error message if an error occurs in uploading. To change the wp-config.php file for your installation, you will need this information: Database Name – Database Name used by WordPress PHP Magic Constants. To get the absolute path to the directory where the current file is located use the __DIR__ magic constant. Note: The contents of the wp-config-sample.php file are in a very specific order. PHP Constants are variables whose values once defined cannot be changed and these constants are defined without a $ sign in the beginning. echo "We are in the file:" , __FILE__ , "\n"; Current directory. ... By default, the configuration pertaining to errors is found in the following directives within the configuration file php.ini. PHP Logging Basics. The order matters. This function takes two parameters first is the name and second is the value of the constant defined. Using Error Constants. __CLASS__ – The class name. This is most often used as a logging/debugging technique.

If you already have a wp-config.php file, rearranging the contents of the file may create errors on your blog. ... and in fact is not bundled in PHP 7. __DIR__ – The directory of the file. In the PHP constants chapter we've learned how to define and use constants in PHP script.. PHP moreover also provide a set of special predefined constants that change depending on where they are used.

__METHOD__ – The class method name.