Home  >  Article  >  Backend Development  >  php syntax error

php syntax error

藏色散人
藏色散人Original
2019-10-11 09:58:153956browse

php syntax error

php常见语法错误

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

1、代码

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

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;;
?>

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

三: 缺少括号引起的错误

1、代码

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

2、运行结果

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

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

1、代码

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

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

五: 语法错误特点

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!

Statement:
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