So you’ve been slinging resumes for a while and now you have an interview for an awesome PHP job. While part of the interview will be the typical job interview, you should also be prepared for a technical interview. Technical interviews are often given to determine how well you truly know the technologies with which you’ll be working. There are numerous books and articles to help you prepare for the job interview portion but very little has been said on preparing for a PHP technical interview.
General PHP Questions
The first type of questions you’ll be asking in a PHP interview will be general questions about PHP itself. Typically, technical interviewers like to start with easy general questions about PHP such as special output tags, how to pass parameters, how to define constants and how to define variables. Depending on the interviewers own technical background, they may progress to questions on more advanced usage such as the object oriented features of PHP. Spend some time prior to your interview to brush up somewhat on the basics of the language. A quick read of a basic PHP book like PHP and MySQL Web Development (4th Edition) may help you review the high points.
Q: What’s a PHP Session?
A: PHP Session is an object created by the PHP engine that persists data between HTTP requests
Q: What are tags = ?> used for?
A: They allow to output the result of the expression between the tags directly to the browser response.
Q: How do you define a constant?
A: define(“CONSTANT_NAME”, “constant value”);
Q: How would you get the number of parameters passed into a method?
A: use the fun_num_args() call within the method
If you are having a PHP interview, it is pretty likely that you are interviewing for some type of web development job. That means it is almost certain that MySQL will be used. You should expect to be asked some questions about accessing MySQL from PHP in your interview. These questions don’t always get very deep. If you can describe how to connect to a database and execute a simple select query, you will likely pass your PHP interview.
Q: How would you create a MySQL database from PHP?
A: mysql_query(“CREATE DATABASE db_name” connector);
Q: How would you see all tables in a database?
A: mysql> use db_name; show tables;
Q: How do you change a password for a given user via mysqladmin utility?
A: mysqladmin -u root -p password “newpassword”
Larger companies and web development shops are increasingly moving towards frameworks in their development. If you want to pass a PHP interview, you should at least know what a framework is, what the most popular frameworks are and know a little about some of their features. Check out the web site for CakePHP for some simple documentation that will give you an idea of the features and uses of a PHP framework.
Q: What are the advantages of using a PHP framework?
A: Code reuse, multitude of service APIs, code modularity with Model-View-Controller (MVC) pattern, community support, and multitude of plugins.
The final category of questions in a PHP interview typically covers best practices. You may be asked about architectural concepts such as scaling an application in PHP. You can easily find a number of useful articles on the subject. You may also be asked about security in PHP. You should be able to describe how to prevent common web based attacks such as SQL injection or cross site scripting from PHP.
During the interview, you want to appear relaxed and confident in your knowledge. Take a moment to really listen to the question before you answer. When you do answer, provide the shortest answer possible. You don’t need a lengthy explanation and you do not want to appear to be rambling. Simply answer the question as succinctly as possible.
Passing a PHP interview is really quite easy if you have a good grasp of the language and take the time to review material that an interviewer is likely to ask about. Know the basics of the language syntax. Don’t limit your review to PHP though. Many PHP interviews WILL include questions about frameworks, security, MySQL and architecture. Relax and answer the question as succinctly as you can. Good luck!
Help us spread the word!
If you liked this article, consider enrolling in one of these related courses:
|Apr 20-21||Web Development with PHP/MySQL|
|- Classroom - Online|