PHP Parse Error: syntax error, unexpected $end 錯(cuò)誤的解決辦法
更新時(shí)間:2012年06月05日 10:35:11 作者:
今天幫客戶配置服務(wù)器,訪問(wèn)php的時(shí)候提示PHP Parse Error: syntax error, unexpected $end 錯(cuò)誤,通過(guò)查找找到了問(wèn)題,特分享下
這幾天寫php程序,感覺(jué)很多地方不如asp,asp.Net,jsp順手,比如session使用先得session_start();,文件跳轉(zhuǎn)header用的也不方便....
也許是不熟悉的php的一些特性吧,不過(guò)寫多了,也就慢慢適應(yīng)將就了.....
這里就整理一個(gè)代碼編寫調(diào)試問(wèn)題,錯(cuò)誤如下:
Parse error: syntax error, unexpected $end in D:\xampp\htdocs\guestBook\guestBook.php on line 330
看看程序 330行,代碼最后一行,這有什么錯(cuò)誤?google搜,找到了:
In PHP 5, the following error may appears as an error entry in Apache error log or simply displays on PHP web page, even if calling to php scripts with php_info() works perfectly and successfully returns information on PHP configurations:
Parse Error: syntax error, unexpected $end in ….. scripts.php on line …
The error may caused by a missing curly bracket in PHP script coding. Beside, it may also caused by error in PHP coding in class definition, as in PHP, a class definition cannot be broke up and distributed into multiple files, or into multiple PHP blocks, unless the break is within a method declaration.
But more commonly, the error is often caused by the use of Short Open tags in PHP,
To use short open tags, it must be enabled in PHP.INI. Search for short_open_tag in PHP.INI, and change the value to On. The line should look line:
short_open_tag = On
欺我英文不好???看看其它幾條搜索,都沒(méi)說(shuō)到點(diǎn)子上,那就看看英文了,雖不能如數(shù)翻譯,大致意思是瞧明白了:
錯(cuò)誤發(fā)生是使用了短標(biāo)簽,可以在php.ini中設(shè)置short_open_tag = On
原來(lái)Parse error 提示一般是 語(yǔ)法錯(cuò)誤,使用了開放的標(biāo)簽,語(yǔ)句沒(méi)有結(jié)束 也就是編程基本的一些錯(cuò), 比如沒(méi)注意 語(yǔ)句結(jié)束加 ";" 或者 if(){...} 后面忘了"}" ;<?php...?>忘了"?>"。仔細(xì)檢查代碼,果然是一處漏掉了"}",修改程序正常運(yùn)行
也許是不熟悉的php的一些特性吧,不過(guò)寫多了,也就慢慢適應(yīng)將就了.....
這里就整理一個(gè)代碼編寫調(diào)試問(wèn)題,錯(cuò)誤如下:
Parse error: syntax error, unexpected $end in D:\xampp\htdocs\guestBook\guestBook.php on line 330
看看程序 330行,代碼最后一行,這有什么錯(cuò)誤?google搜,找到了:
In PHP 5, the following error may appears as an error entry in Apache error log or simply displays on PHP web page, even if calling to php scripts with php_info() works perfectly and successfully returns information on PHP configurations:
Parse Error: syntax error, unexpected $end in ….. scripts.php on line …
The error may caused by a missing curly bracket in PHP script coding. Beside, it may also caused by error in PHP coding in class definition, as in PHP, a class definition cannot be broke up and distributed into multiple files, or into multiple PHP blocks, unless the break is within a method declaration.
But more commonly, the error is often caused by the use of Short Open tags in PHP,
To use short open tags, it must be enabled in PHP.INI. Search for short_open_tag in PHP.INI, and change the value to On. The line should look line:
short_open_tag = On
欺我英文不好???看看其它幾條搜索,都沒(méi)說(shuō)到點(diǎn)子上,那就看看英文了,雖不能如數(shù)翻譯,大致意思是瞧明白了:
錯(cuò)誤發(fā)生是使用了短標(biāo)簽,可以在php.ini中設(shè)置short_open_tag = On
原來(lái)Parse error 提示一般是 語(yǔ)法錯(cuò)誤,使用了開放的標(biāo)簽,語(yǔ)句沒(méi)有結(jié)束 也就是編程基本的一些錯(cuò), 比如沒(méi)注意 語(yǔ)句結(jié)束加 ";" 或者 if(){...} 后面忘了"}" ;<?php...?>忘了"?>"。仔細(xì)檢查代碼,果然是一處漏掉了"}",修改程序正常運(yùn)行
您可能感興趣的文章:
- PHP syntax error, unexpected $end 錯(cuò)誤的一種原因及解決
- 記錄PHP錯(cuò)誤日志 display_errors與log_errors的區(qū)別
- PHP函數(shù)之error_reporting(E_ALL ^ E_NOTICE)詳細(xì)說(shuō)明
- PHP中error_reporting()函數(shù)的用法(修改PHP屏蔽錯(cuò)誤)
- PHP異常Parse error: syntax error, unexpected T_VAR錯(cuò)誤解決方法
- ThinkPHP頁(yè)面跳轉(zhuǎn)success與error方法概述
- php error_log 函數(shù)的使用
- PHP錯(cuò)誤Parse error: syntax error, unexpected end of file in test.php on line 12解決方法
- ThinkPHP跳轉(zhuǎn)頁(yè)success及error模板實(shí)例教程
- PHP常見(jiàn)的6個(gè)錯(cuò)誤提示及解決方法
相關(guān)文章
記錄PHP錯(cuò)誤日志 display_errors與log_errors的區(qū)別
錯(cuò)誤回顯,一般常用語(yǔ)開發(fā)模式,但是很多應(yīng)用在正式環(huán)境中也忘記了關(guān)閉此選項(xiàng)。錯(cuò)誤回顯可以暴露出非常多的敏感信息,為攻擊者下一步攻擊提供便利。推薦關(guān)閉此選項(xiàng)2012-10-10
php實(shí)現(xiàn)數(shù)字補(bǔ)零的方法總結(jié)
這篇文章給大家總結(jié)了關(guān)于php實(shí)現(xiàn)數(shù)字補(bǔ)零的方法以及相關(guān)代碼分享,有興趣的朋友們學(xué)習(xí)下。2018-09-09
PHP工廠模式簡(jiǎn)單實(shí)現(xiàn)方法示例
這篇文章主要介紹了PHP工廠模式簡(jiǎn)單實(shí)現(xiàn)方法,簡(jiǎn)單說(shuō)明了工廠模式的概念、原理并結(jié)合實(shí)例形式分析了php實(shí)現(xiàn)工廠模式的相關(guān)操作技巧,需要的朋友可以參考下2018-05-05
php實(shí)現(xiàn)的仿阿里巴巴實(shí)現(xiàn)同類產(chǎn)品翻頁(yè)
當(dāng)前頁(yè)左邊的頁(yè)碼為最新的產(chǎn)品,按更新時(shí)間呈升序排列;右邊的頁(yè)碼為早期的產(chǎn)品, 按更新時(shí)間呈降序排列。2009-12-12
php做下載文件的實(shí)現(xiàn)代碼及文件名中亂碼解決方法
php做下載文件的實(shí)現(xiàn)代碼及文件名中亂碼解決方法,需要的朋友可以參考下。2011-02-02
PHP 雜談《重構(gòu)-改善既有代碼的設(shè)計(jì)》之五 簡(jiǎn)化函數(shù)調(diào)用
前幾篇系列文章,我比較關(guān)注的是 PHP 雜談《重構(gòu)-改善既有代碼的設(shè)計(jì)》之一 重新組織你的函數(shù) 但是我覺(jué)得我還是沒(méi)有說(shuō)清楚,我自己也有很多不理解的地方,而且這篇是我的第一篇這方面的文章,有很多的紕漏,所以我會(huì)經(jīng)常性的去做修改,如果大家有好的意見(jiàn)不妨告知一、二2012-05-05

