From dc1c759c2903f15fd3c52c2241c765c65fbe9d89 Mon Sep 17 00:00:00 2001 From: Rudy Affandi Date: Sat, 31 Oct 2015 11:27:13 -0700 Subject: [PATCH] Add the rest of the magic constants --- php.html.markdown | 28 ++++++++++++++++++++++++++-- 1 file 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