I have a raw php (vanilla php) script and upgraded php v8.1.0. And now I don't want to run the script in a lower version of that. I want to make that check-in raw PHP as I don't have a composer or don't use any framework, how can I do that?
Actually I want to make a checking of my own third level number like
if ('7.4.9' > '8.1.0') not using php built in function in some case we also see version: '^7.4'. In that case what also can be done.
Can anyone give any suggestions please, or anywhere I can get the answers?
I think you mean vanilla PHP instead of raw PHP. You can test the PHP version into the script like this:
if (phpversion() < '8.1.0') {
die ('At least PHP version 8.1.0 is required');
}
If you need a more granular comparison on the subversion or on the release version you can use version_compare() which does all dirty job for you:
if (version_compare(phpversion(), '8.1.0', '<')) {
die ('At least PHP version 8.1.0 is required');
}
Constants are also available 'for all tastes':