PRQ PHP
PRQ PHP
echo can take mul ple parameters, while print can take only one argument.
Example:
php
CopyEdit
$$var is a variable variable (the name of the variable is stored in another variable).
Example:
php
CopyEdit
$var = "name";
$name = "John";
Returns:
Example:
php
CopyEdit
Example:
php
CopyEdit
$a = "Hello ";
$b = "World!";
var_dump() displays structured informa on about variables: type, length, and value.
Example:
php
CopyEdit
$a = array(1, 2, 3);
var_dump($a);
Compila on Usually compiled (e.g., C, C++) Usually interpreted (e.g., PHP, Python)
Syntax Example:
php
CopyEdit
$marks = 75;
} else {
Use Case Best for range or complex condi ons Best for comparing one variable to many values
Readability Clearer for complex logic Best for simple condi ons
con nue: Skips current itera on and moves to the next loop cycle.
PRACTICAL RELATED QUESTIONS
php
CopyEdit
<?php
$n = 10;
$first = 0;
$second = 1;
$first = $second;
$second = $next;
?>
php
CopyEdit
<?php
$n = 20;
$isPrime = true;
if ($i % $j == 0) {
$isPrime = false;
break;
if ($isPrime) {
?>
An anonymous func on in PHP is a func on without a name. It is also called a closure and is o en
used for callbacks or when a short func on is needed temporarily.
Syntax Example:
php
CopyEdit
};
2. Write the difference between built-in func on and user-defined func on.
Usage Can be used directly without defining Must be defined before use
A variable func on in PHP means calling a func on using a variable that holds its name. The variable
behaves like a func on name.
Example:
php
CopyEdit
func on greet() {
echo "Hello!";
$func = "greet";