0

Basic PHP Quiz - 5

Description: Basic PHP Quiz - 5
Number of Questions: 10
Created by:
Tags: php
Attempted 0/10 Correct 0 Score 0

Include files must have the file extension ".inc"

php
  1. True

  2. False


Correct Option: B

In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings:

php
  1. True

  2. False


Correct Option: A

What is the correct way to create a function in PHP?

php
  1. function myFunction()

  2. new_function myFunction()

  3. create myFunction()


Correct Option: A
php
  1. mysql_open("localhost");

  2. connect_mysql("localhost");

  3. dbopen("localhost");

  4. mysql_connect("localhost");


Correct Option: D
php
  1. count++;

  2. $count++;

  3. ++count

  4. $count =+1


Correct Option: B

Which one of these variables has an illegal name?

php
  1. $my-Var

  2. $myVar

  3. $my_Var


Correct Option: A
Explanation:

To determine which variable has an illegal name, we need to understand the rules for variable naming conventions.

In most programming languages, variables can be named using letters, numbers, and underscores. However, there are some restrictions:

  1. The variable name cannot start with a number.
  2. The variable name cannot contain spaces or special characters, except for underscores.

Now let's analyze each option:

A. $my-Var: This variable name uses a hyphen (-) between "my" and "Var". Hyphens are not allowed in variable names in most programming languages, so option A has an illegal name.

B. $myVar: This variable name uses only letters and does not contain any illegal characters. Option B has a legal name.

C. $my_Var: This variable name uses an underscore (_) between "my" and "Var". Underscores are commonly used in variable names and are allowed in most programming languages. Option C has a legal name.

Therefore, the variable with the illegal name is:

The Answer is: A. $my-Var

- Hide questions