From db690c17c5335b746e3e7867e3d7cf5aab724a9a Mon Sep 17 00:00:00 2001 From: Rudy Affandi Date: Sat, 31 Oct 2015 10:54:55 -0700 Subject: Add PHP magic constants entry --- php.html.markdown | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 0504ced2..06a289f4 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -765,6 +765,13 @@ I'm a ParentClass But I'm ChildClass */ +/********************** +* Magic constants +* +*/ + +// Get directory of the file +require __DIR__ . '/vendor/autoload.php'; /********************** * Error Handling -- cgit v1.2.3 From dc1c759c2903f15fd3c52c2241c765c65fbe9d89 Mon Sep 17 00:00:00 2001 From: Rudy Affandi Date: Sat, 31 Oct 2015 11:27:13 -0700 Subject: Add the rest of the magic constants --- php.html.markdown | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'php.html.markdown') 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 -- cgit v1.2.3