gpt4 book ai didi

php - 如何解释 php_uname 的输出

转载 作者:行者123 更新时间:2023-12-04 18:32:31 24 4
gpt4 key购买 nike

来自 manual我得到了信息:

mode is a single character that defines what information is returned:

'a': This is the default. Contains all modes in the sequence "s n r v m".
's': Operating system name. eg. FreeBSD.
'n': Host name. eg. localhost.example.com.
'r': Release name. eg. 5.1.2-RELEASE.
'v': Version information. Varies a lot between operating systems.
'm': Machine type. eg. i386.

所以我创建了一个函数
function interpret_php_uname(){
$release_info["os_name"] = php_uname('s');
$release_info["uname_version_info"] = php_uname('v');
$release_info["machine_type"] = php_uname('m');
$release_info["php_uname"] = php_uname();
return $release_info;
}

有没有办法从我在 Ubuntu 上的 uname 获取更多有用的信息?
Linux geisterhaufen 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

尤其是 找出分布 (俏皮的“Ubuntu 13.10”)来自我机器上的“uname_version_info”部分:
#23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013

最佳答案

<?php
function interpret_php_uname(){
$release_info["os_name"] = php_uname('s');
$release_info["uname_version_info"] = php_uname('v');
$release_info["machine_type"] = php_uname('m');
$release_info["kernel"] = php_uname('r');
$release_info["php_uname"] = php_uname();

$distribution["4.10"]=array("Warty Warthog", "2.6.8");
$distribution["5.04"]=array("Hoary Hedgehog", "2.6.10");
$distribution["5.10"]=array("Breezy Badger", "2.6.12");
$distribution["6.06"]=array("Dapper Drake", "2.6.15");
$distribution["6.10"]=array("Edgy Eft", "2.6.17");
$distribution["7.04"]=array("Feisty Fawn", "2.6.20");
$distribution["7.10"]=array("Gutsy Gibbon", "2.6.22");
$distribution["8.04"]=array("Hardy Heron", "2.6.24");
$distribution["8.10"]=array("Intrepid Ibex", "2.6.27");
$distribution["9.04"]=array("Jaunty Jackalope", "2.6.28");
$distribution["9.10"]=array("Karmic Koala", "2.6.31");
$distribution["10.04"]=array("Lucid Lynx", "2.6.32");
$distribution["10.10"]=array("Maverick Meerkat", "2.6.35");
$distribution["11.04"]=array("Natty Narwhal", "2.6.38");
$distribution["11.10"]=array("Oneiric Ocelot", "3.0");
$distribution["12.04"]=array("Precise Pangolin", "3.2");
$distribution["12.10"]=array("Quantal Quetzal", "3.5");
$distribution["13.04"]=array("Raring Ringtail", "3.8");
$distribution["13.10"]=array("Saucy Salamander", "3.11");
$distribution["14.04"]=array("Trusty Tahr", "3.13");

foreach($distribution as $distribution=>$name_kernel){
list($name,$kernel)=$name_kernel;
if(version_compare($release_info["kernel"],$kernel,'>=')) {
$release_info["ubuntu_distribution"]=$distribution;
$release_info["ubuntu_distribution_name"]=$name;
}
}

return $release_info;
}
$release_info=interpret_php_uname();
var_export($release_info);

将打印例如:
array (
'os_name' => 'Linux',
'uname_version_info' => '#23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013',
'machine_type' => 'x86_64',
'kernel' => '3.11.0-15-generic',
'php_uname' => 'Linux geisterhaufen 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64',
'ubuntu_distribution' => '13.10',
'ubuntu_distribution_name' => 'Saucy Salamander',
)

关于php - 如何解释 php_uname 的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21129737/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com