Monday, March 7, 2016

Interview - 2 - PHP - Answers



Back - Interview Questions - 2

Q1.  What’s the special meaning of __sleep and __wakeup?

Ans. __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

Q2. How do you call a constructor for a parent class?
Ans. parent::constructor($value)

Q3. Are objects passed by value or by reference?
 Ans. Everything is passed by value

Q4. What’s the difference between accessing a class method via -> and via ::?
 Ans. :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.

Q5. If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?
Ans. 100, it’s a reference to existing variable.

No comments:

Post a Comment