The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications.
PHP Interviews are getting tough these days as the technology grows faster. To get through the PHP interview one needs to update him/herself in a regular manner. Having said that, just before the interview, it is very important to have a quick glance of the reputed PHP questions and answers to make yourself comfortable during the interview process. This is where DoAnswers.com helps you in renewing yourself on PHP and various other technologies interview preparation.
21. Why doesn't the following code print the newline properly?
Because inside the single quotes the \n character is not interpreted as newline, just as a sequence of two characters \ and n.
22. Will comparison of string "10" and integer 11 work in PHP?
Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
23. With a heredoc syntax, do I get variable substitution inside the heredoc contents?
Yes. I want to combine two variables together: $var1 = 'Welcome to '; $var2 = 'TechInterviews.com';
24. Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?
In this example it wouldn?t matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces.
25. Would you initialize your strings with single quotes or double quotes?
Since the data inside the single-quoted string is not parsed for variable substitution, it?s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution.