0

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

6
  • 1
    It looks like you are using left and right quotes, try retyping that in a plain text editor like Notepad (Windows), TextEdit (Mac), or gedit (linux). That way it will have normal quotes, e.g. ". Note: In TextEdit you will need to press Cmd+Shift+T to make it plain text. Commented Jul 8, 2012 at 12:33
  • yes thanks so much.. i was using wordpad thanks so much i will get some good php editor as you said thanks so much Commented Jul 8, 2012 at 12:35
  • @DeepakKumar If you don't want to go all out and use an IDE, I found that TextPad is a great basic editor to work with. Allows multiple files open at once, can do syntax highlighting and has line numbering. You really don't want too much else to start with. Commented Jul 8, 2012 at 12:37
  • @Fluffeh Thanks for telling me i will get it now Commented Jul 8, 2012 at 12:39
  • Notepad++ is the absolute best text editor. Commented Jul 8, 2012 at 12:39

4 Answers 4

4

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

<?php
$myName = 'Guest';
$myVar = "Welcome back $myName";
echo $myVar;
?>
Sign up to request clarification or add additional context in comments.

1 Comment

for adding help ( in my case - I forgot the ( ; ) semicolon on the previous line )
1

you need to write

$myVar = "Welcome Back $myName";

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

Comments

0
<?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.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.