PHP Interview Questions and Answers
Difficulty Level: AllBeginnerIntermediateExperienced/Expert
Ques 1. When are you supposed to use endif to end the conditional statement?
Ques 2. Explain the ternary conditional operator in PHP?
Ques 3. How do I find out the number of parameters passed into function?
Ques 5. What's the difference between accessing a class method via -> and via ::?
Ques 6. Are objects passed by value or by reference?
Ques 7. How do you call a constructor for a parent class?
Ques 8. What's the special meaning of __sleep and __wakeup?
Ques 10. Would you initialize your strings with single quotes or double quotes?
Ques 12. What is the difference between characters 23 and x23?
Ques 13. With a heredoc syntax, do I get variable substitution inside the heredoc contents?
Ques 14. I want to combine two variables together:
Ques 15. For printing out strings, there are echo, print and printf. Explain the differences.
Ques 17. What's the difference between htmlentities() and htmlspecialchars()?
Ques 18. What's the difference between md5(), crc32() and sha1() crypto on PHP?
Ques 20. How do you match the character ^ at the beginning of the string?
Ques 21. What does a special set of tags <?= and ?> do in PHP?
Ques 22. What's the difference between include and require? -
Ques 25. How do you define a constant?
Ques 26. How do you pass a variable by value?
Ques 27. Will comparison of string "10" and integer 11 work in PHP?