PHP Parse Error: syntax error, unexpected $end 錯誤的解決辦法
更新時間:2012年06月05日 10:35:11 作者:
今天幫客戶配置服務(wù)器,訪問php的時候提示PHP Parse Error: syntax error, unexpected $end 錯誤,通過查找找到了問題,特分享下
這幾天寫php程序,感覺很多地方不如asp,asp.Net,jsp順手,比如session使用先得session_start();,文件跳轉(zhuǎn)header用的也不方便....
也許是不熟悉的php的一些特性吧,不過寫多了,也就慢慢適應(yīng)將就了.....
這里就整理一個代碼編寫調(diào)試問題,錯誤如下:
Parse error: syntax error, unexpected $end in D:\xampp\htdocs\guestBook\guestBook.php on line 330
看看程序 330行,代碼最后一行,這有什么錯誤?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
欺我英文不好?。靠纯雌渌鼛讞l搜索,都沒說到點(diǎn)子上,那就看看英文了,雖不能如數(shù)翻譯,大致意思是瞧明白了:
錯誤發(fā)生是使用了短標(biāo)簽,可以在php.ini中設(shè)置short_open_tag = On
原來Parse error 提示一般是 語法錯誤,使用了開放的標(biāo)簽,語句沒有結(jié)束 也就是編程基本的一些錯, 比如沒注意 語句結(jié)束加 ";" 或者 if(){...} 后面忘了"}" ;<?php...?>忘了"?>"。仔細(xì)檢查代碼,果然是一處漏掉了"}",修改程序正常運(yùn)行
也許是不熟悉的php的一些特性吧,不過寫多了,也就慢慢適應(yīng)將就了.....
這里就整理一個代碼編寫調(diào)試問題,錯誤如下:
Parse error: syntax error, unexpected $end in D:\xampp\htdocs\guestBook\guestBook.php on line 330
看看程序 330行,代碼最后一行,這有什么錯誤?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
欺我英文不好?。靠纯雌渌鼛讞l搜索,都沒說到點(diǎn)子上,那就看看英文了,雖不能如數(shù)翻譯,大致意思是瞧明白了:
錯誤發(fā)生是使用了短標(biāo)簽,可以在php.ini中設(shè)置short_open_tag = On
原來Parse error 提示一般是 語法錯誤,使用了開放的標(biāo)簽,語句沒有結(jié)束 也就是編程基本的一些錯, 比如沒注意 語句結(jié)束加 ";" 或者 if(){...} 后面忘了"}" ;<?php...?>忘了"?>"。仔細(xì)檢查代碼,果然是一處漏掉了"}",修改程序正常運(yùn)行
您可能感興趣的文章:
- PHP syntax error, unexpected $end 錯誤的一種原因及解決
- 記錄PHP錯誤日志 display_errors與log_errors的區(qū)別
- PHP函數(shù)之error_reporting(E_ALL ^ E_NOTICE)詳細(xì)說明
- PHP中error_reporting()函數(shù)的用法(修改PHP屏蔽錯誤)
- PHP異常Parse error: syntax error, unexpected T_VAR錯誤解決方法
- ThinkPHP頁面跳轉(zhuǎn)success與error方法概述
- php error_log 函數(shù)的使用
- PHP錯誤Parse error: syntax error, unexpected end of file in test.php on line 12解決方法
- ThinkPHP跳轉(zhuǎn)頁success及error模板實(shí)例教程
- PHP常見的6個錯誤提示及解決方法
相關(guān)文章
PHP實(shí)現(xiàn)可精確驗(yàn)證身份證號碼的工具類示例
這篇文章主要介紹了PHP實(shí)現(xiàn)可精確驗(yàn)證身份證號碼的工具類,涉及php針對字符串的截取、計(jì)算、判斷等相關(guān)操作技巧,并附帶說明了身份證號碼的原理,需要的朋友可以參考下2018-05-05php中preg_replace_callback函數(shù)簡單用法示例
這篇文章主要介紹了php中preg_replace_callback函數(shù)簡單用法,分析了preg_replace_callback函數(shù)的功能及簡單使用方法,需要的朋友可以參考下2016-07-07redis+php實(shí)現(xiàn)微博(一)注冊與登錄功能詳解
這篇文章主要介紹了redis+php實(shí)現(xiàn)微博注冊與登錄功能,結(jié)合實(shí)例形式分析了php結(jié)合redis實(shí)現(xiàn)微博注冊及登錄相關(guān)操作步驟與實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-09-09火車采集器 免費(fèi)版使出收費(fèi)版本功能實(shí)現(xiàn)原理
火車頭免費(fèi)版本不支持采集結(jié)果的外掛處理,比如采用php來輔助處理結(jié)果,而火車頭本身對于正則表達(dá)式的不完整支持,2009-09-09將PHP從5.3.28升級到5.3.29時Nginx出現(xiàn)502錯誤
這篇文章主要介紹了將PHP從5.3.28升級到5.3.29時Nginx出現(xiàn)502錯誤,需要的朋友可以參考下2015-05-05