Which symbol is used to start a variable in PHP?
A
@ B
$ C
# D
%
Analysis & Theory
In PHP, all variables start with the `$` symbol, like `$name`.
How do you end a PHP statement?
A
With a colon `:` B
With a comma `,` C
With a semicolon `;` D
With a period `.`
Analysis & Theory
PHP statements are terminated by a semicolon (`;`).
Which of the following is the correct way to start a PHP block?
A
<php> B
<?php C
<? D
</php>
Analysis & Theory
A PHP block starts with `<?php` and ends with `?>`.
How do you write a single-line comment in PHP?
A
# This is a comment B
// This is a comment C
/* This is a comment */ D
Both A and B
Analysis & Theory
PHP supports single-line comments with `#` and `//`, and multi-line with `/* ... */`.
Which of the following is the correct syntax to output 'Hello World' in PHP?
A
echo 'Hello World'; B
print('Hello World') C
echo('Hello World'); D
All of the above
Analysis & Theory
In PHP, `echo 'Hello World';`, `echo('Hello World');`, and `print('Hello World')` are all valid.
Which tag is used to close a PHP block?
A
</php> B
?> C
<endphp> D
//>
Analysis & Theory
A PHP block ends with `?>`.
How do you declare a constant in PHP?
A
$PI = 3.14; B
const PI = 3.14; C
define('PI', 3.14); D
Both B and C
Analysis & Theory
PHP constants are declared using `const` or `define()`.
What is the correct way to write an if statement in PHP?
A
if (condition) then { } B
if condition { } C
if (condition) { } D
if [condition] { }
Analysis & Theory
The correct syntax is `if (condition) { // code }` in PHP.
Which one is a correct way to start a while loop in PHP?
A
while (condition) { } B
while condition { } C
while [condition] { } D
loop while (condition) { }
Analysis & Theory
The correct syntax is `while (condition) { // code }`.
How do you include an external PHP file in your script?
A
import 'file.php'; B
include 'file.php'; C
using 'file.php'; D
require 'file.php';
Analysis & Theory
`include 'file.php';` inserts the content of one PHP file into another. Alternatively, `require` does the same but throws an error if the file is missing.