what is the output here?

<?php
$x = 'Sunil';
echo ‘Hello $x’;

?>

a. hello sunil
b. Parse error
c. hello $x
d. syntax error

ANS: c

published by www.w3answers.com

ans

b is correct answer....
if u see echo line 3 its -> echo `hello $x`;
and not echo 'hello $x';

so it will throw a parse error....:)

Actual answer follows...

$x = 'Sunil';
echo "Hello $x";

?>
answer : Hello Sunil

$x = 'Sunil';
echo 'Hello $x';

?>
ans:c => Hello $x

Actual answer follows...

$x = 'Sunil';
echo "Hello $x";

?>
answer : Hello Sunil

$x = 'Sunil';
echo 'Hello $x';

?>
ans:c => Hello $x

Ans:- b Parse error: parse

$x = 'Sunil';
echo ‘Hello $x’;

?>

Ans:- b
Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in C:\wamp\www\exp.cpp

New Answer

ans:b

Output of the given program

Output of the given program will be syntax error.
ans: d
When line echo 'hello $x'; will execute it will give following error:Parse error: parse error, expecting `','' or `';''

output

Make sure you are using single quote....

Single quote will not parse PHP variables and there will be no such parse error in this case. And there is no question of being a syntax error too

the ans: c

the ans must be c because

the ans must be c because echo 'Hello $x';every thing in between "" or '' is string it not depend on the variable that declare above so Hello $x is the string because it is in single '' so the ans is Hello $x

c

c

php

$x = 'Sunil';
echo ‘Hello $x’;

?>
ans:b

$x = 'Sunil';
echo 'Hello $x';

?>
ans:c

C is correct answer

C is correct answer

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.