summaryrefslogtreecommitdiffhomepage
path: root/php.html.markdown
diff options
context:
space:
mode:
authorRudy Affandi <rudy@adnetinc.com>2015-10-31 11:27:13 -0700
committerRudy Affandi <rudy@adnetinc.com>2015-10-31 11:27:13 -0700
commitdc1c759c2903f15fd3c52c2241c765c65fbe9d89 (patch)
treeaedd8fd5c2e1d10835ef8540f9ccdb5c21e772fc /php.html.markdown
parentdb690c17c5335b746e3e7867e3d7cf5aab724a9a (diff)
Add the rest of the magic constants
Diffstat (limited to 'php.html.markdown')
-rw-r--r--php.html.markdown28
1 files changed, 26 insertions, 2 deletions
diff --git a/php.html.markdown b/php.html.markdown
index 06a289f4..5034cfd1 100644
--- a/php.html.markdown
+++ b/php.html.markdown
@@ -770,8 +770,32 @@ But I'm ChildClass
*
*/
-// Get directory of the file
-require __DIR__ . '/vendor/autoload.php';
+// Get current class name. Must be used inside a class declaration.
+echo "Current class name is " . __CLASS__;
+
+// Get full path directory of a file
+echo "Current directory is " . __DIR__;
+
+ // Typical usage
+ require __DIR__ . '/vendor/autoload.php';
+
+// Get full path of a file
+echo "Current file path is " . __FILE__;
+
+// Get current function name
+echo "Current function name is " . __FUNCTION__;
+
+// Get current line number
+echo "Current line number is " . __LINE__;
+
+// Get the name of the current method. Only returns a value when used inside a trait or object declaration.
+echo "Current method is " . __METHOD__;
+
+// Get the name of the current namespace
+echo "Current namespace is " . __NAMESPACE__;
+
+// Get the name of the current trait. Only returns a value when used inside a trait or object declaration.
+echo "Current namespace is " . __TRAIT__;
/**********************
* Error Handling