PHP_MySQL_Lab_Viva
PHP_MySQL_Lab_Viva
A: PHP originally stood for 'Personal Home Page', but now it stands for 'Hypertext
Preprocessor'. It is a widely-used open source server-side scripting language.
A: A variable is used to store data. It starts with a $ symbol. E.g., $name = 'John';
A: Constants are like variables but once defined, they cannot be changed. Defined using
define(): E.g., define('PI', 3.14);
A: Used inside a class to refer to the current object. E.g., $this->name = 'Student';
A: A number that reads the same forwards and backwards. Example: 121
A: A function calling itself with smaller inputs. E.g., fib(n) = fib(n-1) + fib(n-2)
A: To send form data to the server. GET appends to URL, POST is sent in request body.
A: Use loops and check divisibility conditions. A number is prime if divisible only by 1
and itself.
A: GET (not secure) sends data via URL; POST sends it securely via HTTP body.
Example: form method='post'
A: Built-in variables like $_GET, $_POST, $_SESSION used to manage global data.
A: echo is faster and can print multiple values, while print returns 1. Example: echo 'Hi';
A: Checking user inputs before processing. Example: validate empty fields or email
format.
Q: What is PDO?
A: PHP Data Objects for accessing databases securely using prepared statements.
Q: What are magic constants in PHP?