PHP Interview Questions and Answers
Intermediate / 1 to 5 years experienced level questions & answers
Ques 1. What's the difference between include and require? -
It's how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
Ques 2. Will comparison of string "10" and integer 11 work in PHP?
Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
Ques 3. Are objects passed by value or by reference?
Everything is passed by value.
Ques 4. What's the special meaning of __sleep and __wakeup?
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
Ques 5. What's the difference between htmlentities() and htmlspecialchars()?
htmlspecialchars only takes care of <, >, single quote ', double quote " and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.
Ques 6. How do you match the character ^ at the beginning of the string?
^^
Most helpful rated by users:
- What does a special set of tags <?= and ?> do in PHP?
- What's the difference between include and require? -
- I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what's the problem?
- How do you define a constant?
- Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?