Reputation: 413
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
Reputation: 57
Write $myVar = “Welcome back" . $myName;
instead $myVar = “Welcome back $myName";
<?php
$myName = ‘Guest’;
$myVar = “Welcome back" . $myName;
echo $myVar;
?>
Upvotes: 0
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
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
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