PHP 错误解析错误:语法错误,第 7 行 [location]index.php 中出现意外的“<”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31791019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:36:37  来源:igfitidea点击:

PHP error Parse error: syntax error, unexpected '<' in [location]index.php on line 7

phphtmlcentos

提问by Matthew Correa

i am sorta new to PHP, i mostly use HTML. I have made a PHP script. What the code should do is display a youtube video when i put the code. like this "website.com/youtube.php?v=1010111" It would display the youtube video but I keep on getting the error :

我对 PHP 有点陌生,我主要使用 HTML。我已经制作了一个 PHP 脚本。代码应该做的是在我放置代码时显示 youtube 视频。像这样“website.com/youtube.php?v=1010111”它会显示youtube视频,但我不断收到错误:

Parse error: syntax error, unexpected '<' in [location]/index.php on line 7

解析错误:语法错误,第 7 行 [location]/index.php 中出现意外的“<”

Here is the code:

这是代码:

<?php
if( $_GET["v"])
{
$matches = $_GET['v'];
 echo "Welcome ". $_GET['v']. "<br />";

 <html>

 <iframe width="560" height="315" src="https://www.youtube.com/embed/" </html><?php . $_GET['v'].  ?> <html>frameborder="0" allowfullscreen></iframe>

</html>     
exit();
}
?>
<html>
<body>
<form action="<?php $_PHP_SELF ?>" method="GET">
Name: <input type="text" name="v" />
<input type="submit" />
</form>
</body>
</html>

回答by alfallouji

You have to write ?>when you want to stop writing PHP code.

你必须写?>,当你想停止编写PHP代码。

At line 7, ou have <html>, just write ?>before that html tag.

在第 7 行,您<html>只需?>在该 html 标记之前写上。