PHP Design Patterns PHP Job Interview Questions

As a PHP contractor, consultant, and freelancer, Larry Truett from San Diego, CA going by the alias Fluffycat had a fair number of interviews – and sometimes he’s been asked technical questions. Here are a few to help you prepare for your next PHP job interview.

=,==,=== – what is the difference between these?

= assigns a value, == checks if value is the same, === checks if value is the same and the variables are of the exact same type.

Echo, print, printf – what is the difference between these?

Print and echo both output what is passed to them. Print acts like a function, so you can use it in complex statements. Printf is used to format the output.

Include, include once, require – what is the difference between these?

Include will includes a file each time it is called. Include_once would only include a file one time, so if a php program has a file in two include_once statements only the first will be done. Requre is like include, but if the file included is not available a fatal error occurs and processing stops.

Are variables passed to functions by reference or value?

A variable is passed by value unless the variable is passed with an &, such as functionName(&$variableName)

How do you encrypt data?

The PHP crypt() function can be used to encrypt data. (Honestly, the one time I had this question I drew a complete blank on the function name, so I’m not exactly certain what they were looking for.)

What editor or ide do you use?

Interesting question, probably does say something about your programming capabilites. I use Eclipse 3.1 with PHP extensions, and interviewers seem to like that. There are probably others such as Zend Studio that are also fine answers. Serious Unix users would be good with vi or emacs.

PHP Statics, what are they and how do you use them?

As with Java, if the job is for OO PHP (that is PHP 5), there will be a question on PHP static variables. You may be asked how to reference a static from inside and outside of the class it is in, or just show that you get the basic concept of a variable or function that is for the whole class and not an instance.

Design Patterns general questions

Now we are really into OO stuff. As in java job interviews I’ve usually been asked about design patterns in fairly vague terms, such as “describe the design patterns used in the systems you have worked on”. I was asked that so much that I drew out some UML to bring with me to interviews, as I found drawing up the UML during the interview to be distracting and slow.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s