作为一个PHP编程新手,在PHP编程中,重用代码的时候经常会遇到:syntax error, unexpected end of file这样的错误,今天我来总结一下这种错误发生的情况以及解决办法。

syntax error就是句法错误、语法错误的意思,通过网络搜索发现常见错误原因如下:
1、定界符:定界符的结尾字符一定要另起一行,并且结尾定界符前不能有任何字符;
2、括号:语句中成对符号匹配不完整,如循环语句中的小括号、花括号等;
3、将PHP代码段写成短标签形式,但是没有在php.ini中开启短标签,即将short_open_tag设置为On;

4、PHP代码段中某些代码缺少了分号。