How to get version of PCRE (bundled with PHP) from code?

泄露秘密 提交于 2019-12-02 01:29:08

问题


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

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.

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?


回答1:


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

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




回答2:


You can also use constant PCRE_VERSION

found source here



来源:https://stackoverflow.com/questions/9663572/how-to-get-version-of-pcre-bundled-with-php-from-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!