程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> Call to undefined function imagettftext()解決方法,calltoundefined

Call to undefined function imagettftext()解決方法,calltoundefined

編輯:關於PHP編程

Call to undefined function imagettftext()解決方法,calltoundefined


由 老高 發表於 2014-10-03  在 代碼人生 分類

老高在一個新環境中裝DEDECMS的時候發現後台驗證碼無法顯示。直接搜索一下這個錯誤,有人說session錯誤,有的說權限錯誤等等,這不胡扯麼!只能看源代碼了,定位到文件/include/vdimgck.php。出錯的函數是imagettftext(),由於織夢使用了@將錯誤隱去,導致這次莫名的錯誤。將@去掉,錯誤立馬出現:

Fatal error: Call to undefined function imagettftext()

現在我們就明確了,出現錯誤的原因是PHP編譯時沒有加上FreeType。

解決辦法:

首先編譯安裝FreeType,以2.4.0為例:

wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2
tar -jxf freetype-2.4.0.tar.bz2
cd reetype-2.4.0
# 安裝到/usr/local/freetype
./configure --prefix=/usr/local/freetype
make && make install

下面我們重新編譯PHP,加上參數--with-freetype-dir=/usr/local/freetype

./configure \
... \
... \
--with-freetype-dir=/usr/local/freetype

編譯完成重啟php

kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`

再GD庫中找到FreeType Support說明安裝成功!

需要注意的是,如果服務器freetype的版本是1.*,那麼你可能需要改變編譯參數為--with-ttf[=DIR],以下轉自ChinaUnix論壇:

字庫 配置開關
FreeType 1.x 要激活 FreeType 1.x 的支持,加上 --with-ttf[=DIR]。
FreeType 2 要激活 FreeType 2 的支持,加上 --with-freetype-dir=DIR。
T1lib 要激活 T1lib(Type 1 字體),加上 --with-t1lib[=DIR]。
本地 TrueType 字符串函數 要激活本地 TrueType 字符串函數的支持,加上 --enable-gd-native-ttf。

參考:

http://bbs.chinaunix.net/thread-610205-1-1.html

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved