Thursday, June 17, 2010

PHP - Interview questions - VI

Q: 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.

Q: Why doesn’t the following code print the newline properly?   
            $str = ‘Hello, there.nHow are you?nThanks for visiting TechInterviews’;
            print $str;
    ?>
   
Ans: Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters - and n.