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

Answer & Solution

Answer: Option C
Solution:
Variable names in PHP cannot contain hyphens (-), so $my-var is not a valid variable name.
Related Questions on Average

What does the phpinfo() function do in PHP?

A). Displays information about the PHP environment

B). Executes SQL queries

C). Validates user input

D). Encrypts data transmission

What does the PHP statement echo 'Hello, World!'; do?

A). Prints 'Hello, World!' to the browser

B). Declares a variable named 'Hello, World!'

C). Performs a calculation

D). Defines a function named 'Hello, World!'

Which of the following is a valid PHP constant?

A). MY_CONST

B). $myConst

C). MY_CONST

D). myConst

Which of the following is true about PHP comments?

A). Comments are ignored by the PHP interpreter

B). Comments can only be single-line

C). Comments must start with /* and end with */

D). Comments are displayed on the webpage

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

A). To print human-readable information about a variable

B). To redirect output to a file

C). To execute SQL queries

D). To define a function in PHP

Which of the following is true about PHP variables?

A). Variables must be declared before use

B). Variable names are case-insensitive

C). Variables cannot be reassigned

D). Variables can only store integers

Which of the following PHP tags is used to start and end a block of PHP code?

A). <?php ?>

B). <? ?>

C). <script>

D). <php >

Which of the following is NOT a valid PHP comparison operator?

A). <=

B). ==

C). <>

D). !

Which of the following is true about PHP data types?

A). PHP is a strongly typed language

B). Variables must be explicitly declared with data types

C). PHP supports dynamic typing

D). PHP only supports numeric data types

What is the purpose of the PHP require_once statement?

A). To include and evaluate an external PHP file only once

B). To create a loop in PHP

C). To define a function in PHP

D). To execute a SQL query