PHP Introduction
- Which of following variables can be assigned a value to it?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
A variable can’t start with a number. Also $this is a special variable that can’t be assigned, but $This can be assigned.
- Which of the following php statement/statements will store 120 in variable n?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
You need not specify the datatype in php.
- What will be the output of the following php code?
<?php
$n = 10;
$n1 = 12;
print $n . "+". $n1;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
.(dot) is used to combine two parts of the statement. Example ( $n. “Hello World” ) will output 10Hello World.
- What will be the output of the following php code?
<?php
$n = "12";
$n1 = "21";
print $n+$n1;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
The numbers inside the double quotes are considered as integers and not string, therefore the value 33 is printed and not 12+21.
- Which of the following PHP statements will output Hello interview Mania on the screen?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
echo(), print() and printf() all three can be used to output a statement onto the screen. The sprintf() statement is functionally identical to printf() except that the output is assigned to a string rather than rendered to the browser.