Question 1
In PHP, which magic constant would dynamically contain the full path and filename of the file where it is used, even if that file is included from another script?
- __FILE__
- __DIR__
- __PATH__
- _FILENAME_
- __LINE__
Question 2
Suppose you have an undefined variable $foo; which PHP error type will be triggered when you try to echo $foo, and what is its impact on script execution?
- Notice; script continues to run
- Fatal Error; script execution stops
- Warning; script continues to run
- Parse Error; script execution stops before running
- Strict Error; script ignores the error
Question 3
Consider the two PHP comparison operations: (1) 0 == '0' and (2) 0 === '0'. What will be the respective results of these evaluations and why?
- (1) true, (2) false; == checks value, === checks type and value
- (1) false, (2) true; == checks type and value, === checks value only
- (1) false, (2) false; PHP does not allow such comparisons
- (1) true, (2) true; both operators check only value
- (1) error, (2) false; == throws a warning
Question 4
If you use the require() statement to include a missing PHP file, what will happen to script execution, and how does this differ from include()?
- A fatal error occurs and execution stops; include() only generates a warning
- The script continues as normal in both cases
- A notice is triggered and execution continues
- Nothing happens, both silently ignore the error
- Both result in fatal errors
Question 5
Given a scenario where you need to safely insert user data into a SQL table, which PDO technique best prevents SQL injection and why?
- Using prepared statements with bound parameters to separate query and data
- Interpolating user data directly into SQL strings
- Filtering input with htmlentities() before queries
- Escaping quotes manually using addshlashes()
- Switching database engines frequently