Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

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 4. If the variable $a is equal to 5 and variable $b is equal to character a, what's the value of $$b?

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 9. Why doesn't the following code print the newline properly?                 $str = 'Hello, there.nHow are you?
            print $str;

Ques 10. Would you initialize your strings with single quotes or double quotes?

Ques 11. How come the code <?php print "Contents: $arr[1]"; ?> works, but <?php print "Contents: $arr[1][2]"; ?> doesn't for two-dimensional array of mine? -

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 16. I am writing an application in PHP that outputs a printable version of driving directions. It contains some long sentences, and I am a neat freak, and would like to make sure that no line exceeds 50 characters. How do I accomplish that with PHP?

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 19. So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()?

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 23. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what's the problem?

Ques 24. Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?

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?

©2022 WithoutBook