Q
Which of the following is a correct way to start a PHP script?

Answer & Solution

Answer: Option A
Solution:
The correct opening tag for PHP code is <?php ?>, which indicates the start of PHP code execution within an HTML document.
Related Questions on Average

What is the output of the following PHP code? <?php echo 'Hello, World!'; ?>

A). Hello, World!

B). <?php echo 'Hello, World!'; ?>

C). <?php echo 'Hello, World!'; ?>;

D). <?php echo 'Hello, World!'; ?>;

What is the purpose of the PHP include statement?

A). To include and evaluate an external PHP file

B). To create a loop in PHP

C). To define a function in PHP

D). To execute a SQL query

What is the purpose of the PHP exit() function?

A). To terminate script execution

B). To display a message and exit

C). To redirect to another URL

D). To close a database connection

Which of the following is a correct way to define a constant in PHP?

A). define('MY_CONST', 'value');

B). $MY_CONST = 'value';

C). const MY_CONST = 'value';

D). MY_CONST = 'value';

What file extension is commonly used for PHP scripts?

A). .php

B). .html

C). .js

D). .css

What is the output of the following PHP code? <?php $x = 5; $y = 10; echo $x + $y; ?>

A). 15

B). 5 + 10

C). $x + $y

D). 510

Which of the following is NOT a valid PHP variable name?

A). $my_var

B). $myVar

C). $my-var

D). $myVar123

What is the purpose of the PHP echo statement?

A). To output data to the browser

B). To define a function

C). To include an external file

D). To declare a variable

Which of the following is used to comment out a single line of PHP code?

A). //

B). /* */

C). <!-- -->

D). <?php ?>

Which of the following is used to concatenate strings in PHP?

A). .

B). +

C). ,

D). -