Skip to main content

Posts

Showing posts with the label Data Types What are the main data types in PHP? File Inclusion Difference between include and require? Database Security How to connect to MySQL securely?OOP Basics Explain class

Top 10 Essential PHP Interview Questions & Answers

P - PHP learning Tool practice MCQS  P1. What are the main data types in PHP? PHP supports scalar types: int, float, string, bool; compound types: array, object; and special types: null, resource. PHP is loosely typed – variables are cast automatically based on context. --- 2. What is the difference between include and require? · include emits a warning and continues execution if the file is not found. · require throws a fatal error and stops the script.   Use require for critical dependencies (e.g., configuration), include for optional content. --- 3. Explain PHP superglobals. Name a few. Superglobals are built-in variables available in all scopes. Key ones: · $_GET – URL query parameters · $_POST – form data sent via HTTP POST · $_SESSION – session data · $_COOKIE – client-side cookies · $_SERVER – server and execution environment info · $_FILES – uploaded files --- 4. How do you connect to a MySQL database securely? Use PDO or MySQLi wit...