PHP Design Patterns .

PHP Design Patterns PHP Job Interview Questions

As a PHP contractor, consultant, and freelancer I've had a fair number of interviews - and sometimes I have 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. The PHP md5() function is very pretty widely used, but is a one way hash, and can not be decrypted. (Honestly, the one time I had this question I drew a complete blank, 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 with PHP extensions, and interviewers seem to like that. There are probably others such as Zend Studio that are also excellent 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.

Comments Comments are left by visitors to and may or may not be accurate.
Comment by Larry on 2015-10-03 Rate this Comment

Something very odd happened to me last week in an interview, and I didn't realize it until a while afterwards. It was an interview for a job using OO PHP 5, and I was NOT asked about statics. Hard to tell yet if this is a new trend or not.

Comment by dagadakanth on 2009-04-21 Rate this Comment

Be the first to comment on PHP Design Patterns PHP Job Interview Questions.

Sign in to comment on PHP Design Patterns PHP Job Interview Questions.