Monday, December 06, 2010

PHP Interview Questions and Tips

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.

Sample Questions

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

MySQL

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.

Sample Questions

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”

PHP Frameworks

Read more: Learn computer