Wh1T3h4Ck5
Wh1T3h4Ck5

Reputation: 8509

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

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?

Upvotes: 4

Views: 3878

Answers (2)

MaxXx1313
MaxXx1313

Reputation: 610

You can also use constant PCRE_VERSION

found source here

Upvotes: 6

Another Code
Another Code

Reputation: 3151

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.

Upvotes: 2

Related Questions