This article describes the simplest code to use php to obtain information about PHP, MySQL, and Apache versions. It can be done with only one sentence of code, which is very practical. This article describes the simplest code to use php to obtain information about PHP, MySQL, and Apache versions. It can be done with only one sentence of code, which is very practical.
Script ec (2); script
Sometimes the PHP + MYSQL + Apache application we install or develop requires the Environment version, at this time, we can use the following code to query the PHP, MySQL, and Apache version information to see if it meets our needs.
1. directly obtain the PHP version
Echo 'php version: '. phpversion ();
?>
2. Obtain the MySQL version directly.
Mysql_connect ('2017. 0.0.1 ', 'root ','');
Echo 'mysql version: '. mysql_get_server_info ();
?>
3. Obtain the Apache version
Echo 'apache version: '. apache_get_version ();
?>
To query more detailed PHP configurations, use the following code:
Phpinfo ();
?>
Common Methods for viewing version information in linux, apache, php, and mysql
1. view the linux kernel versionThere are three common methods for system information:
Uname-a; more/etc/issue; cat/proc/version;
2. View apache version informationIf it is installed through yum or rpm, you can use rpm-qa | gerp httpd to view it;
It can also be queried through httpd-v;
Of course, after installing apache, you can directly query apache information through the elink loop.
3. View php version informationIf the package is installed using yum or rpm, you can use rpm-qa | grep php to view the package;
You can also use php-v to view the php version information;
Generally, you can use the phpinfo test page after installing lamp to view the installed php information;
The specific method is to create the index. php file under/var/www/. The specific content is
Php phpinfo ();
?>
You can. Add the index. php type to the/etc/httpd/conf/httpd. conf file and restart httpd. the following result is displayed.
4. View mysql version informationIf it is installed through yum or rpm package, you can use rpm-qa | grep mysql to view it;
You can also use mysql-v or -- help | grep Distrib to view it;
You can also go to mysql and run select version;
Or status; command to view.
I personally think that these are commonly used methods. Of course, there will certainly be more effective and convenient methods and approaches.