PHP Web Developer
Basic to Intermediate Interview
Questions
Q: What is PHP?
A: PHP is a server-side scripting language designed for web development but also
used as a general-purpose language.
Q: What are the common uses of PHP?
A: PHP is used to create dynamic websites, interact with databases, handle forms,
manage sessions, and build APIs.
Q: What is the difference between echo and print in PHP?
A: Both output data to the screen, but echo is faster and can take multiple
parameters; print returns a value (1), so it can be used in expressions.
Q: What is a session in PHP?
A: A session stores user data across multiple pages using a unique session ID saved
on the server.
Q: What is a cookie in PHP?
A: A cookie stores small pieces of data on the client's browser to remember user
preferences or login info.
Q: How do you connect to a MySQL database using PHP?
A: Using mysqli_connect() or with PDO
Q: What is the difference between GET and POST methods?
A: GET sends data via URL and is visible; POST sends data in the body, more secure
for sensitive info
Q: What are PHP data types?
A: String, Integer, Float, Boolean, Array, Object, NULL, and Resource
Q: What is an associative array?
A: An array that uses named keys that you assign to each value.
Q: What is the difference between include() and require()?
A: require() halts the script if the file is missing; include() gives a warning but
continues.
APTECH JOB FAIR 2025
PHP Web Developer
Q: What is a constructor in PHP?
A: It is a special method (__construct) that runs automatically when an object is
created.
Q: What is the purpose of isset()?
A: It checks whether a variable is set and not NULL
Q: What is the explode() function?
A: It splits a string into an array based on a delimiter
Q: What is SQL Injection?
A: A malicious technique to execute unwanted SQL commands by manipulating
input fields.
Q: How can you prevent SQL Injection?
A: Use prepared statements with PDO or MySQLi
Q: What is OOP in PHP?
A: Object-Oriented Programming lets you structure code using classes, objects, and
methods for reusability and clarity
Q: What are magic methods in PHP?
A: Special functions like __construct(), __destruct(), __get(), __set(), etc., used for
handling object behavior.
Q: How is error handling done in PHP?
A: Using try, catch, and finally blocks or custom error handlers with
set_error_handler().
Q: What is Composer?
A: Composer is a dependency manager for PHP that helps install and manage
external packages and libraries.
Q: What is the difference between == and === in PHP?
A: == checks value equality (with type conversion), while === checks value and type
both
APTECH JOB FAIR 2025