Call to undefined function imagettftext()解決方案,calltoundefined_PHP教程

來源:互聯網
上載者:User

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.bz2tar -jxf freetype-2.4.0.tar.bz2cd reetype-2.4.0# 安裝到/usr/local/freetype./configure --prefix=/usr/local/freetypemake && 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

http://www.bkjia.com/PHPjc/1110532.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1110532.htmlTechArticleCall to undefined function imagettftext()解決方案,calltoundefined 由老高發表於2014-10-03 在代碼人生分類 老高在一個新環境中裝DEDECMS的時候發現後台驗...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.