Editing
Troubleshooting of PHP errors
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== 執行PHP時顯示原始碼的錯誤 === 確認伺服器是否能執行 PHP * 驗證方式: ** 網頁伺服器放置寫了 [http://php.net/manual/en/function.phpinfo.php phpinfo] 的 PHP 檔案,看是否可以顯示結果。使用後建議移除該檔案,避免對外揭露伺服器環境資訊。或 ** {{kbd | key = <nowiki>php -v</nowiki>}} 如果可以顯示 PHP 版本資訊,代表有安裝 PHP 成功。 * 解決方式: ** 不能執行 PHP 的話,需要檢查 [http://php.net/manual/en/install.php 安裝 PHP] 步驟。 如果 PHP 使用 short tag 語法撰寫,但是沒有啟用 short_open_tag ,會造成顯示原始碼的錯誤。 * 驗證方式: ** 輸入指令 {{kbd | key = <nowiki>php -i | grep short_open_tag</nowiki>}} 確認結果為 short_open_tag = Off * 解決方式: ** 法1: 啟用 short_open_tag (1) php.ini 檔案 需要開啟 short_open_tag = Off -> On (2) 重新啟動網頁伺服器服務,讓 php.ini 修改生效 (3) 驗證 short_open_tag = On ** 法2: 不啟用 short_open_tag,將多個 PHP 檔案的 {{kbd | key=<nowiki><? </nowiki>}} 改成 {{kbd | key=<nowiki><?php </nowiki>}}。 (1) 使用支援 [[Regular expression]] 的文字編輯軟體、(2) 搜尋 {{kbd | key=<nowiki><\?\s</nowiki>}} 取代為 {{kbd | key=<nowiki><\?php </nowiki>}} 。請注意取代部分結尾有一個空白。詳見 [[Batch remove PHP short tags]]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information