Quiz about Variables & Data Types in PHP

Variables & Data Types in PHP

Last Updated :
Discuss
Comments

Question 1

Which function is used to check the data type of a variable in PHP?

  • A

    gettype()

  • B

    var_type()

  • C

    checktype()

  • D

    type_of()

Question 2

What is the result of the following PHP code: $x = "10" + 5;?

  • A

    10

  • B

    15

  • C

    "105"

  • D

    Error

Question 3

Which of the following is not a scalar data type in PHP?

  • A

    integer

  • B

    float

  • C

    string

  • D

    array

Question 4

How do you declare a variable in PHP?

  • A

    $variable;

  • B

    var variable;

  • C

    let variable;

  • D

    declare variable;

Question 5

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

  • A

    define("PI", 3.14);

  • B

    const PI = 3.14;

  • C

    constant("PI", 3.14);

  • D

    Both a) and b)

Question 6

What is the default value of an uninitialized variable in PHP?

  • A

    null

  • B

    false

  • C

    0

  • D

    "" (empty string)

Question 7

Which of the following is the correct way to declare a global variable in PHP?

  • A

    global $var;

  • B

    $GLOBALS['var'];

  • C

    global variable $var;

  • D

    Both a) and b)

Question 8

Which of the following is the correct way to create a null variable in PHP?

  • A

    $var = null;

  • B

    $var = "";

  • C

    $var = false;

  • D

    $var = undefined;

Question 9

How do you declare a floating-point variable in PHP?

  • A

    $var = "4";

  • B

    $var = 3.14;

  • C

    $var = 3,14;

  • D

    $var = float(3.14);

Question 10

What is the proper way to define an array in PHP?

  • A

    $arr = array(1, 2, 3);

  • B

    $arr = (1, 2, 3);

  • C

    $arr = [1, 2, 3];

  • D

    Both a) and c)

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion