解析错误:语法错误,C:\xampp\htdocs\yo\index中的意外T_STRING。php在第3行

时间:2021-09-05 22:45:55

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

我是php新手,我正在尝试添加这段代码

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

这是我的html

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

Thanks

谢谢

4 个解决方案

#1


4  

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

看起来你用的是有趣的引号,而不是直接的'和'类型。

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

#2


1  

you need to write

你需要写

$myVar = "Welcome Back $myName";

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

问题是您对引号字符使用了错误的字符

#3


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.

这就是在连接字符串时代码的工作方式。

#4


0  

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

写入$myVar =“欢迎回来”。美元的名字;相反,$myVar =“欢迎返回$myName”;

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

#1


4  

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

看起来你用的是有趣的引号,而不是直接的'和'类型。

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

#2


1  

you need to write

你需要写

$myVar = "Welcome Back $myName";

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

问题是您对引号字符使用了错误的字符

#3


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.

这就是在连接字符串时代码的工作方式。

#4


0  

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

写入$myVar =“欢迎回来”。美元的名字;相反,$myVar =“欢迎返回$myName”;

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