Deepak Kumar
Deepak Kumar

Reputation: 413

Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\yo\index.php on line 3

I am new on php and i am trying to add this code

Im finding this error please any one who can solve this for me

<?php
$myName = ‘Guest’;
$myVar = “Welcome back $myName”;
echo $myVar;
?>

This is my html

<p><?php echo $myVar; ?></p>

Thanks

Upvotes: 0

Views: 23326

Answers (4)

manoj03h
manoj03h

Reputation: 57

Write $myVar = “Welcome back" . $myName; instead $myVar = “Welcome back $myName";

<?php
$myName = ‘Guest’;
$myVar = “Welcome back" . $myName;
echo $myVar;
?>

Upvotes: 0

sarojrana
sarojrana

Reputation: 186

<?php
    $myName = "Guest";
    $myVar = "Welcome back ".$myName;
    echo $myVar;
?>

or

<?php
    $myName = "Guest";
    $myVar = "Welcome back $myName";
    echo $myVar;
?>

This is how code works while concatenating the string.

Upvotes: 0

mfadel
mfadel

Reputation: 897

you need to write

$myVar = "Welcome Back $myName";

the problem is that you are using the wrong char for the quote character

Upvotes: 1

Fluffeh
Fluffeh

Reputation: 33532

Looks like you are using funny quotes rather than the straight ' and " types.

<?php
$myName = 'Guest';
$myVar = "Welcome back $myName";
echo $myVar;
?>

Upvotes: 4

Related Questions