Which function is used to define a constant in PHP?
A
const() B
define() C
set_const() D
constant()
Analysis & Theory
`define()` is used to create a constant in PHP.
Which keyword can also be used to define a constant in PHP?
A
var B
constant C
const D
let
Analysis & Theory
`const` can also be used to define constants, typically outside of functions.
What is the output of the magic constant `__LINE__`?
A
The current filename B
The current line number C
The current function name D
The current class name
Analysis & Theory
`__LINE__` returns the current line number in the PHP file.
What does the magic constant `__FILE__` return?
A
The current file path B
The current line number C
The current function name D
The current directory
Analysis & Theory
`__FILE__` returns the full path and filename of the current file.
Which magic constant returns the directory of the current file?
A
__FILE__ B
__LINE__ C
__DIR__ D
__PATH__
Analysis & Theory
`__DIR__` returns the directory of the current file.
Are constants case-sensitive by default in PHP?
A
Yes B
No C
Sometimes D
Depends on server
Analysis & Theory
Constants are case-sensitive by default unless specified otherwise in older PHP versions.
What does the magic constant `__FUNCTION__` return?
A
The current class name B
The current function name C
The current file name D
The current method name
Analysis & Theory
`__FUNCTION__` returns the name of the current function.
Which magic constant returns the current class name?
A
__FUNCTION__ B
__CLASS__ C
__FILE__ D
__METHOD__
Analysis & Theory
`__CLASS__` returns the name of the current class.
What is the output of the magic constant `__METHOD__`?
A
The current function name B
The current method name with class C
The current file name D
The directory name
Analysis & Theory
`__METHOD__` returns the current class method name, including the class name.
Which magic constant shows the name of the current trait?
A
__TRAIT__ B
__CLASS__ C
__METHOD__ D
__FUNCTION__
Analysis & Theory
`__TRAIT__` returns the name of the current trait in PHP.