🚀
Q1. How to prevent SQL injection?
A. Use prepared statements with bound parameters (PDO/mysqli). Never concatenate user input into SQL.
Advanced
🚀
Q2. What is CSRF and how to mitigate it?
A. Cross-site request forgery. Mitigate with CSRF tokens, SameSite cookies, and origin checks.
Advanced
🚀
Q3. How should passwords be stored?
A. Use password_hash (bcrypt/argon2) and password_verify. Never store plaintext or MD5/SHA1 hashes.
Advanced
🚀
Q4. What is OPCache?
A. Caches compiled PHP bytecode to speed up performance and reduce CPU overhead.
Advanced
🚀
Q5. What is dependency injection?
A. Passing dependencies into classes/functions instead of creating them inside; improves testability.
Advanced
🚀
Q6. What is a middleware pattern?
A. A pipeline that processes requests/responses in steps (common in frameworks).
Advanced
🚀
Q7. How to handle errors in production?
A. Disable display_errors, log errors, use centralized error handlers, and show user-friendly pages.
Advanced
🚀
Q8. What is XSS?
A. Injecting scripts into pages. Prevent with escaping, sanitization, and strict CSP.
Advanced