- These are PHP frameworks used for faster development.
- Laravel → most popular, modern syntax.
- CodeIgniter → lightweight, easy to learn.
- Symfony → enterprise-level, modular.
Category: Interview Questions
-
Laravel, CodeIgniter, and Symfony?
-
prevent SQL Injection in PHP?
Use Prepared Statements with PDO or mysqli.
$stmt = $conn->prepare("SELECT * FROM users WHERE email = ?"); $stmt->bind_param("s", $email); $stmt->execute();
-
four pillars of OOP in PHP?
- Encapsulation – Wrapping data & methods in a class.
- Abstraction – Hiding implementation details.
- Inheritance – Reusing parent class in child class.
- Polymorphism – Same method name with different behavior.
-
handle errors in PHP?
error_reporting()
try {} catch {}
blocksset_error_handler()
try {
} catch (Exception $e) {throw new Exception("Error occurred!");
}echo $e->getMessage();
-
connect PHP with MySQL?
$conn = new mysqli("localhost", "root", "", "testdb"); if ($conn->connect_error) {
}die("Connection failed!");
-
sessions and cookies in PHP?
- Sessions: Store data on the server, unique for each user.
- Cookies: Store data on the client/browser.
-
include and require?
include
→ gives a warning if file missing, script continues.require
→ gives a fatal error and stops execution.
-
superglobals in PHP?
Predefined global arrays available anywhere in PHP:
$_GET
– data from URL query string$_POST
– data from forms$_SESSION
– session variables$_COOKIE
– cookies$_SERVER
– server/environment info$_FILES
– file uploads$_REQUEST
– combines GET + POST + COOKIE
-
== and === in PHP?
==
checks for value equality (ignores type).===
checks for value and type equality.
var_dump(5 == "5"); // true var_dump(5 === "5"); // false
-
What are PHP data types?
- String
- Integer
- Float (double)
- Boolean
- Array
- Object
- NULL