PHP __DIR__, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, __NAMESPACE__ - Comment Page: 1
PHP has large number of predefined constants. This HOWTO will present the seven most important, most practical and most useful PHP Magic Constants.
__FILE__ - 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.
__LINE__ - The current line number of the file.
__NAMESPACE__ - The name of the current namespace
This is example PHP script with comments, which demonstrate howto use all previously mentioned PHP Magic Constants.
[inttf_post_ad1]
<?php
// Set namespace (works only with PHP 5.3)
namespace TestProject;
// This...
[…] Message Magic and Skype VS Twitter Broadcasting Holiday Joy | Message Magic ProTwitter Bot: Magic 8 Ball « Matt's BlogThe Magic of Twitter | bitcolumnstech news that mattersTwitter Business Magic PLR « Web 2.0 « JEDsWEBHowto Use PHP Magic Constants: __FILE__, __DIR__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, __N… […]
You’ve got great insights about PHP, keep up the good work!
this awesome tips and shorthand coding for php developers
Just __DIR__ not work… u need define dirname(__DIR__)
Example is correct:
echo dirname(__FILE__);
Thanks for sharing
This is really great
Thanks For the detailed article.
good tutorial, thx.