从 PHP 脚本检测是否启用了 mbstring

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14871842/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 08:07:04  来源:igfitidea点击:

Detect if mbstring is enabled or not from PHP script

phpmbstring

提问by Jayakrishnan

How can I check if the mbstring extension is loaded in a php script?

如何检查 mbstring 扩展名是否已加载到 php 脚本中?

回答by Frosty Z

Use if (extension_loaded('mbstring')) { /* loaded */ }

if (extension_loaded('mbstring')) { /* loaded */ }

See PHP manual.

请参阅PHP 手册

回答by swapnesh

Run this code in php file --

在 php 文件中运行这段代码——

<?php phpinfo(); ?>

mbstring

字符串

回答by Geoffrey Hale

Also useful:

也有用:

php -i | grep mbstring

php -i | grep mbstring

回答by Usersbs

From terminal/console, go in PHP CLI mode and echo the command as below,

从终端/控制台,进入 PHP CLI 模式并回显如下命令,

$ php -a

php > echo extension_loaded('mbstring');
1

It will return 1 if mbstring is loaded as an extension otherwise null

如果 mbstring 作为扩展加载,它将返回 1,否则返回 null

回答by Louis Huppenbauer

Use the extension_loaded class:

使用 extension_loaded 类:

extension_loaded('mbstring');

回答by Rajasekar PHP

You can check it through phpinfo().

您可以通过 phpinfo() 进行检查。

Search for the string "mbstring" in phpinfo page. If it is present means then mbstring is enabled or it is disabled.

在 phpinfo 页面中搜索字符串“mbstring”。如果它存在,则表示启用 mbstring 或禁用它。

回答by Rohollah

if you cannot find mbstring in phpinfo();    
change extension_dir = "ext" to  extension_dir = "c:/php/ext" 
in c:\php\php.ini file