How to get the machine code of my computer in php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
villas
Forum Newbie
Posts: 3
Joined: Mon Nov 18, 2002 5:28 am

How to get the machine code of my computer in php?

Post by villas »

Hi guys,

Can i get the machine code of my computer by a function of PHP, or in other methods in php?

Plz give me a hand~~~

Thanks in advance~~~
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

machine code? hmmm, if you mean IP address it's:

Code: Select all

<?php
$REMOTE_ADDR
or
$REMOTE_HOST
?>
make a blank .php page and type in only phpinfo(); you should get more from there
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

It may be that $REMOTE_ADDR nor $REMOTE_HOST appear to be unavailable to you - if so then try:

Code: Select all

$_SERVERї'REMOTE_ADDR'] 
// or 
$_SERVERї'REMOTE_HOST']
if you have PHP 4.1 or above, or

Code: Select all

$HTTP_SERVER_VARSї'REMOTE_ADDR']
// or 
$HTTP_SERVER_VARSї'REMOTE_HOST']
if you have PHP 4.0.6 or below.

Mac
villas
Forum Newbie
Posts: 3
Joined: Mon Nov 18, 2002 5:28 am

Post by villas »

Dear Oromian,

Thanks first~~~

The machine code is the unique symbol of a computer, but not a IP address...

I didn't have any lights in phpinfo() functions,
Do you have an idea to get it in PHP?
Thanks a lot~~~
villas
Forum Newbie
Posts: 3
Joined: Mon Nov 18, 2002 5:28 am

Post by villas »

please give a hand~~~

Thanks in advance!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

afaik there is no php function to retrieve that kind of information.
But you may use external programs.
with winnt/2k/xp ships a program called ipconfig. ipconfig /all will show all mac addresses of all adapters.
linux/unix systems usually have ifconfig. ifconfig eth0 e.g. shows all infos of adapter eth0.
you can fetch the ouput via exec() and filter it.
e.g.

Code: Select all

ifconfig eth0 | grep "HWaddr" | sed -e 's/.*HWaddr \(.*\)/\1/g'
catches the mac of eth0 at my linux box at bash command line
Post Reply