If I try phpinfo()
I see that System is:
Linux php56-web-68 4.4.0-142-generic #168-Ubuntu
But I have no idea what Ubuntu version is it? Is it 14.04 or 16.04 or something else?
Is there a way I can get this information just using standard PHP?
If I try phpinfo()
I see that System is:
Linux php56-web-68 4.4.0-142-generic #168-Ubuntu
But I have no idea what Ubuntu version is it? Is it 14.04 or 16.04 or something else?
Is there a way I can get this information just using standard PHP?
4
Answers
If you want to check ubuntu version via terminal than you can check it with below command
You can call shell commands with shell_exec();
From that you can parse the info you need.
It’s aviable with this command
Another alternative is to use
cat /etc/lsb-release
command and feed it into PHP’sshell_exec
.shell_exec
should yield similar to this:After that, just use
parse_ini_string
to parse the output, in turn returns an array.Here’s a one liner:
Sidenote: Just tested on my ec2 instance, it yields
18.04
A better version than the previous answer above suggested by @jenesaisquoi: