This section covers the questions for Variables and Data Types to clear all your concepts in PHP.
Question 1
Which function is used to check the data type of a variable in PHP?
gettype()
var_type()
checktype()
type_of()
Question 4
How do you declare a variable in PHP?
$variable;
var variable;
let variable;
declare variable;
Question 5
Which of the following is the correct way to declare a constant in PHP?
define("PI", 3.14);
const PI = 3.14;
constant("PI", 3.14);
Both a) and b)
Question 6
What is the default value of an uninitialized variable in PHP?
null
false
0
""
(empty string)
Question 7
Which of the following is the correct way to declare a global variable in PHP?
global $var;
$GLOBALS['var'];
global variable $var;
Both a) and b)
Question 8
Which of the following is the correct way to create a null variable in PHP?
$var = null;
$var = "";
$var = false;
$var = undefined;
Question 9
How do you declare a floating-point variable in PHP?
$var = "4";
$var = 3.14;
$var = 3,14;
$var = float(3.14);
Question 10
What is the proper way to define an array in PHP?
$arr = array(1, 2, 3);
$arr = (1, 2, 3);
$arr = [1, 2, 3];
Both a) and c)
There are 10 questions to complete.