如何使用PHP获取计算机名称 [英] How can I get Computer Name with PHP

查看:300
本文介绍了如何使用PHP获取计算机名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好..

我有一个问题。如何使用PHP代码获取现在使用的计算机名称?

我总能找到只获得IP地址和服务器名称的php代码,而不是本地计算机名称..

请帮帮我..

谢谢..

解决方案

函数GetComputerName()
{
尝试
{
var network = new ActiveXObject(' WScript.Network');
// 如果有效则显示弹出
alert(network.computerName );
}
catch (e){}
}





这是javascript,有时会在IE中运行。这是你能做的最好的事情。然后,您可以将该值推送到控件中,然后当用户发布到服务器时,您可以在PHP中读取它。 PHP无法做你想要的,因为它运行在服务器上,而不是客户端,所以它无法查找客户端数据。


嗨NurSalsabila,这就是我如何获得计算机姓名



 <?php  
// 按名称获取主机
echo 的gethostname();
echo < br>< /跨度>;
// 获取操作系统
echo php_uname();
?>





:)


< pre><?php 
echo gethostbyaddr(


Hallo..
I have a question. How can I get the computer name that now I use using PHP Code?
I always find php code that get IP addres and server name only, not for local computer name..
help me please..
thank you..

解决方案

function GetComputerName()
{
    try
    {
        var network = new ActiveXObject('WScript.Network');
        // Show a pop up if it works
        alert(network.computerName);
    }
    catch (e) { }
}



This is javascript that will work in IE, sometimes. That's the best you can do. You can then push that value in to a control and then when the user posts to the server, you can read it in PHP. PHP can't do what you want because it runs on the server, not the client, so it can't look up client data.


Hi NurSalsabila , this is how I get the computer name

<?php
//get host by name
echo gethostname();
echo "<br>";
//get OS
echo php_uname();
?>



:)


<pre><?php
	echo gethostbyaddr(


这篇关于如何使用PHP获取计算机名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆