Q. What will be the output of the following PHP code ?

Code:
<?php
$one = "one";
$two = "two";
print("$one$two");
?>
  • (A) onetwo
  • (B) $one$two
  • (C) one
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (A) onetwo

Q. What will be the output of the following PHP code ?

Code:
<?php
$one = "one";
$two = "two";
print($one==$two);
?>
  • (A) true
  • (B) false
  • (C) nothing
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (C) nothing

Q. What will be the output of the following PHP code ?

Code:
<?php
$one = "one";
$two = "one";
print($one == $two);
?>
  • (A) true
  • (B) false
  • (C) 1
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (C) 1

Q. What will be the output of the following PHP code ?

Code:
<?php
print("this"."was"."a"."bad"."idea");
?>
  • (A) thiswasabadidea
  • (B) this was a bad idea
  • (C) nothing
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (A) thiswasabadidea

Q. What will be the output of the following PHP code ?

Code:
<?php
define("GREETING", "PHP is a scripting language");
echo $GREETING;
?>
  • (A) $GREETING
  • (B) no output
  • (C) PHP is a scripting language
  • (D) GREETING
πŸ’¬ Discuss
βœ… Correct Answer: (B) no output

Q. What will be the output of the following PHP code ?

Code:
<?php
define("__LINE__", "PHP is a scripting language");
echo __LINE__;
?>
  • (A) PHP is a scripting language
  • (B) __LINE__
  • (C) 2
  • (D) ERROR
πŸ’¬ Discuss
βœ… Correct Answer: (C) 2

Q. What will be the output of the following PHP code ?

Code:
<?php
define("NEW_GOOD_NAME_CONSTANT", "I have a value");
define("OLD_BAD_NAME_CONSTANT", NEW_GOOD_NAME_CONSTANT);
 
echo NEW_GOOD_NAME_CONSTANT;
echo OLD_BAD_NAME_CONSTANT; 
?>
  • (A) I have a value
  • (B) I have a valueI have a value
  • (C) I have a valueNEW_GOO_NAME_CONSTANTS
  • (D) ERROR
πŸ’¬ Discuss
βœ… Correct Answer: (B) I have a valueI have a value

Q. What will be the output of the following PHP code ?

Code:
<?php
define("VAR_NAME","test"); 
${VAR_NAME} = "value"; 
echo VAR_NAME;
echo ${VAR_NAME}; 
?>
  • (A) test
  • (B) testtest
  • (C) testvalue
  • (D) error, constant value cannot be changed
πŸ’¬ Discuss
βœ… Correct Answer: (C) testvalue

Q. What is PHP?

  • (A) PHP is an open-source programming language
  • (B) PHP is used to develop dynamic and interactive websites
  • (C) PHP is a server-side scripting language
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the mentioned

Q. Which of the following is the correct syntax to write a PHP code?

  • (A) <?php ?>
  • (B) < php >
  • (C) < ? php ?>
  • (D) <? ?>
πŸ’¬ Discuss
βœ… Correct Answer: (D) <? ?>