检测服务器上是否安装了FreeType PHP扩展 [英] Detect if the FreeType PHP extension is installed on the server

查看:102
本文介绍了检测服务器上是否安装了FreeType PHP扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何测试以查看FreeType扩展是否安装在运行PHP的服务器上?

How do I test to see if the FreeType extension is installed on a server running PHP?

我想在自己的网站上制作一个简单的验证码系统,所以我使用了 imagettftext() ,效果很好.但是,如果服务器未安装FreeType库,该怎么办?

I wanted to make a simple CAPTCHA system on my site, so I used imagettftext() and it worked fine. But what if the server didn't have the FreeType library installed?

因此,有一种方法可以通过代码以某种方式检测FreeType库,如果不存在,则退回

So is there a way to somehow detect FreeType library through code, and if it is not present, fall back to something like imagestring()?

如果我不能使用imagettftext(),我可能不得不考虑绘制大字体文本的替代方法,因为imagestring的最大尺寸对于诸如CAPTCHA之类的内容不利.

If I can't use imagettftext() I may have to look at alternatives to draw big font text as the imagestring max size isn't good for something like a CAPTCHA.

推荐答案

使用 function_exists :

if (function_exists('imagettftext')) {
     imagettftext();
} else {
     // do other function
}

希望有帮助.

这篇关于检测服务器上是否安装了FreeType PHP扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆