PHP Velho Oeste 2024

extension_loaded

(PHP 4, PHP 5, PHP 7, PHP 8)

extension_loaded检查一个扩展是否已经加载

说明

extension_loaded(string $extension): bool

检查一个扩展是否已经加载。

参数

extension

扩展名称,大小写不敏感。

你可以用 phpinfo() 来查看一系列扩展名称,而在 CGICLI 的 PHP 版本里你可以使用 -m 参数来列出所有有效的扩展:

$ php -m
[PHP Modules]
xml
tokenizer
standard
sockets
session
posix
pcre
overload
mysql
mbstring
ctype

[Zend Modules]

返回值

如果 extension 指定的扩展已加载,返回 true,否则返回 false

示例

示例 #1 extension_loaded() 示例

<?php
if (!extension_loaded('gd')) {
if (!
dl('gd.so')) {
exit;
}
}
?>

参见

add a note add a note

User Contributed Notes 1 note

up
0
Marl
8 years ago
The explanation above renders this function useless.
I can check phpinfo() to determine the name of the extension.

If it's in the display that proves that it's loaded.

If not, I might know the dll name (php_printer.dll) but I don't know the name of the extension.
To Top