How do I get the PCRE version (bundled with PHP) from code?
Is there a way to get the version (and release date) of PCRE bundled with PHP from PHP code and store it in a variable
I can find it using phpinfo () but cannot find any other way to get this value directly from the code.
I have been trying to find a solution for the last couple of hours but it is hopeless.
So far I can get the full output of phpinfo () in a variable and pull the PCRE version / release date from there, but I'm wondering if there is an easier solution?
source to share
I think there is a class created for this ReflectionExtension
, although I can't seem to get the version from it directly ( getVersion()
returnsnull
). This works :
$pcreReflector = new ReflectionExtension("pcre");
ob_start();
$pcreReflector->info();
$pcreInfo = ob_get_clean(); // Version and release date can be parsed from here
You will still have to parse it, but at least this is only the relevant part, not the whole output phpinfo
.
source to share