Quick Answer
Magic constants change value depending on where they are used. __LINE__ gives current line number, __FILE__ gives full file path, __DIR__ gives directory path, __CLASS__ gives class name, __METHOD__ gives method name, __NAMESPACE__ gives current namespace. Useful for debugging, logging, and building autoloaders. Always available without any import.
Answer
Magic constants like __FILE__, __LINE__, and __DIR__ provide dynamic information depending on where they are used.
S
SugharaIQ Editorial Team
Verified Answer
This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.
PHP interview questions and answers for beginner, junior, mid-level, senior, and expert developers. Ideal for freshers and experienced candidates preparing for PHP roles.