php syntax error

藏色散人
Release: 2023-02-26 09:10:01
Original
3949 people have browsed it

php syntax error

php常见语法错误

一:缺少结束符引起的错误

1、代码

<?php
for($i=1; $i<11; $i++)
{
echo $i //缺少结束符
}
?>
Copy after login

2、运行结果

Parse error: syntax error, unexpected '}', expecting ',' or ';' in D:\AppServ\www\test\22\1\index.php on line 5

二: 缺少单引号或双引号引起的错误

1、代码

<?php
echo "Hello PHP&#39;;
?>
Copy after login

2、运行结果

Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in D:\AppServ\www\test\22\2\index.php on line 3
Copy after login

三: 缺少括号引起的错误

1、代码

<?php
for($i=0; $i<10; $i++)
{
for($j=0; $j<10; $j++)
{
echo $i*$j."<br>";
}
?>
Copy after login

2、运行结果

Parse error: syntax error, unexpected end of file in D:\AppServ\www\test\22\3\index.php on line 9
Copy after login

四: 缺少变量标识符“$”引起的错误

1、代码

<?php
for( $i=1; $i<11; i++){//缺少一个变量的美元符号
echo $i."<br>";
}
?>
Copy after login

2、运行结果

Parse error: syntax error, unexpected &#39;++&#39; (T_INC), expecting &#39;)&#39; in D:\AppServ\www\test\22\4\index.php on line 2
Copy after login

五: 语法错误特点

1、程序还没开始运行。

2、程序报的是Parse error错误。

更多PHP相关知识,请访问PHP中文网

The above is the detailed content of php syntax error. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template