Explore topic-wise MCQs in Php.

This section includes 8 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

1.

What will be the output of the following PHP code?
<?php
define("__LINE__", "She is beautiful");
echo " n";
echo __LINE__;
?>

A. She is beautiful
B. Error
C. Nothing
D. 4
E. None of these
Answer» E. None of these
2.

What will be the output of the following PHP code ?
<?php
class Constants
{
define('MIN_VA', '10.10');
define('MAX_VAL', '20.20');
public static function getMin()
{
return self::MIN_VAL;
}
public static function getMax()
{
return self::MAX_VAL;
}
}
echo Constants::getMin();
echo Constants::getMax();
?>

A. Error
B. 10.10
C. 20.20
D. Nothing
E. None of these
Answer» B. 10.10
3.

What will be the output of the following PHP code ?
<?php
define('ATTENTION_TEXT', 'Interview mania is good website.', true);
echo ATTENTION_TEXt;
$changing_var = 'text';
echo constant('ATTENTION_' . strtoupper($changing_var));
?>

A. Nothing
B. Interview mania is good website.
C. Interview mania is good website.Interview mania is good website.
D. Error
E. None of these
Answer» D. Error
4.

What will be the output of the following PHP code ?
<?php
define("ATTENTION", "Interview mania is good website.", true);
echo $ATTENTION;
?>

A. Interview mania is good website.
B. Error
C. $ATTENTION
D. ATTENTION
E. None of these
Answer» C. $ATTENTION
5.

What will be the output of the following PHP code ?
<?php
define("FIRST_NAME", "Ajit");
define("LAST_NAME", FIRST_NAME);

echo FIRST_NAME;
echo LAST_NAME;
?>

A. Nothing
B. Ajit
C. FIRST_NAME LAST_NAME
D. Error
E. AjitAjit
Answer» F.
6.

What will be the output of the following PHP code ?
<?php
class newObject { }
define('newObject::CONSTANT', 'Example');
echo newObject::CONSTANT;
?>

A. Error
B. Example
C. CONSTANT
D. Nothing
E. None of these
Answer» B. Example
7.

What will be the output of the following PHP code ?
<?php
define("STR_VAR","Interview");
${STR_VAR} = "Mania";
echo STR_VAR;
echo ${STR_VAR};
?>

A. Interview
B. InterveiwMania
C. Error
D. Mania
E. None of these
Answer» C. Error
8.

What will be the output of the following PHP code?
<?php
define('IF', 102);
echo "IF: ", IF;
?>

A. Error
B. Nothing
C. 102
D. IF:102
E. None of these
Answer» B. Nothing