PHP interview questions and answers

PHP interview questions and answers

1)    What does a special set of tags <?= and ?> do in PHP?

2)    What’s the difference between include and require?

3)    I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?

4)    Would I use print “$a dollars” or “{$a} dollars” to print out the amount of dollars in this example?

5)    How do you define a constant?

6)    How do you pass a variable by value?

7)    Will comparison of string “10” and integer 11 work in PHP?

8)    When are you supposed to use endif to end the conditional statement?

9)    Explain the ternary conditional operator in PHP?

10) How do I find out the number of parameters passed into function?

11) If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?

12) What’s the difference between accessing a class method via -> and via ::?

13) Are objects passed by value or by reference?

14) How do you call a constructor for a parent class?

15) What’s the special meaning of __sleep and __wakeup?

16) Why doesn’t the following code print the newline properly?

17) Would you initialize your strings with single quotes or double quotes?

18) 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?

19) What is the difference between characters 23 and x23?

20) With a heredoc syntax, do I get variable substitution inside the heredoc contents?


 Just press Like button to download Answers


You Might Also Like