-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a0befb
commit 65ee6f7
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
namespace MyNamespace; | ||
|
||
// Magic constants demo | ||
echo "Current line number: " . __LINE__ . "<br/>"; // Output current line number | ||
echo "Full file path: " . __FILE__ . "<br/>"; // Output the full path to the file | ||
echo "Directory path: " . __DIR__ . "<br/>"; // Output the directory of the file | ||
|
||
// Function example using __FUNCTION__ | ||
function exampleFunction() { | ||
echo "Function name: " . __FUNCTION__ . "<br/>"; // Output current function's name | ||
} | ||
exampleFunction(); | ||
|
||
// Class example using __CLASS__ | ||
class ExampleClass { | ||
function displayClassName() { | ||
echo "Class name: " . __CLASS__ . "<br/>"; // Output current class's name | ||
} | ||
} | ||
$obj = new ExampleClass(); | ||
$obj->displayClassName(); | ||
|
||
// Method example using __METHOD__ | ||
class MethodExample { | ||
public function showMethodName() { | ||
echo "Method name: " . __METHOD__ . "<br/>"; // Output current method's name | ||
} | ||
} | ||
$obj2 = new MethodExample(); | ||
$obj2->showMethodName(); | ||
|
||
// Namespace example using __NAMESPACE__ | ||
echo "Current namespace: " . __NAMESPACE__ . "<br/>"; | ||
?> |