如何从代码中获取PCRE版本(与PHP捆绑在一起)? [英] How to get version of PCRE (bundled with PHP) from code?

查看:68
本文介绍了如何从代码中获取PCRE版本(与PHP捆绑在一起)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过任何方式获取 PCRE 与PHP代码中的PHP捆绑在一起并将其存储到变量中?

Is there any way to get version (and date of release) of PCRE bundled with PHP from PHP code and store it into variable?

我可以使用 phpinfo()找到它,但找不到找到其他直接从代码中获取该值的方法.

I can found it using phpinfo() but can't find any other way to get that value directly from code.

我试图在最近几个小时内找到解决方案,但这是没有希望的.

I was trying to find solution last couple of hours but it's hopeless.

到目前为止,我可以获取完整的phpinfo()输出变量,并从那里获取PCRE版本/发行日期,但我想知道是否有更简单的解决方案?

So far, I can get complete phpinfo() output in variable and pull out PCRE version/release date from there but I'm wondering is there easier solution?

推荐答案

我认为 <为此创建了c0> 类,尽管我似乎无法直接从中获得版本(getVersion() 返回null ).此可以正常工作:

I think the ReflectionExtension class is made for this, though I can't seem to get the version out of it directly (getVersion() returns null). This does work however:

$pcreReflector = new ReflectionExtension("pcre");
ob_start();
$pcreReflector->info();
$pcreInfo = ob_get_clean(); // Version and release date can be parsed from here

您仍然必须解析它,但至少它只是相关部分,而不是整个phpinfo输出.

You'll still have to parse it, but at least it's just the relevant part and not the entire phpinfo output.

这篇关于如何从代码中获取PCRE版本(与PHP捆绑在一起)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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