php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17400 getting ip for eth0
Submitted: 2002-05-23 20:29 UTC Modified: 2017-11-27 15:20 UTC
Votes:8
Avg. Score:2.9 ± 1.3
Reproduced:3 of 6 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: e at arix dot com Assigned: pollita (profile)
Status: Closed Package: *General Issues
PHP Version: 7.0 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: e at arix dot com
New email:
PHP Version: OS:

 

 [2002-05-23 20:29 UTC] e at arix dot com
I'd like to request a function to retrieve the IP address(es) of a given network interface... something that would let me:

  $ip = ifaddr("eth0");

maybe even something more general like:

  $info = ifconfig("eth0")

echo $info["HWAddr"], $info["Mask"];
echo $info["RX-packets"], $info["RX-errors"],

etc.

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-24 00:37 UTC] mfischer@php.net
If you can think of a cross-platform way ... which I doubt.

Just execute /sbin/ifconfig and parse it's output.
 [2002-05-24 02:22 UTC] derick@php.net
reclassify as feature request
 [2013-10-27 11:05 UTC] krakjoe@php.net
-Package: Feature/Change Request +Package: *General Issues
 [2013-10-27 12:42 UTC] krakjoe@php.net
Because _nobody_ should have to wait more than a decade for a decent answer:

https://gist.github.com/krakjoe/7181349

Not able to attach patch to bug, will do when systems are fixed ... stupid hackers ...

Who is gonna do windows ??
 [2013-10-27 12:47 UTC] krakjoe@php.net
Oh I forgot to mention, we can provide some of the information you requested in a portable (across posix implementations) way. 

It's not so easy to provide RX/TX counters and status.

Providing proper names and addresses should allow you to write the non-portable stuff for the platform you are targeting, in php ...
 [2013-11-05 08:20 UTC] ab@php.net
-Assigned To: +Assigned To: ab
 [2013-11-05 08:20 UTC] ab@php.net
gonna do the windows part
 [2014-12-30 15:14 UTC] tyrael@php.net
-PHP Version: 4.2.1 +PHP Version: 7.0
 [2014-12-30 15:14 UTC] tyrael@php.net
Anatol, any update on this?
 [2014-12-30 16:07 UTC] ab@php.net
Hi Ferenc,

heh, no implementation started, and will not be soon unfortunately. Still too much stuff for master + ongoing bugs for stable branches. Thanks for poking, I'll keep this one in mind (except one took over before).

Cheers

Anatol
 [2015-03-12 09:38 UTC] ab@php.net
got something now

https://github.com/php/php-src/compare/master...weltling:17400

Joe, please check the linux part, ported onto the current master.

Thanks.
 [2015-06-17 12:16 UTC] kalle@php.net
Anatol, question; Why is this integrated in Zend/ and not in main/ where other network related functionality exists?
 [2015-06-17 21:13 UTC] ab@php.net
So was it in the Joe's original patch, I just extended it with the Windows part. But i'm not sure we should take it - Joe seems to be not interested/busy, so I'm not sure a sufficient testing can be done.

Thanks.
 [2017-01-10 06:32 UTC] krakjoe@php.net
I just forgot about this ... it would be nice if we could implement at least one of these 15 year old feature requests ...

I still think this is valuable, many places in php can actually make use of interface names but we still have no good way to determine them.

@ab can you fixup for master please, and open a clean PR on github ?
 [2017-10-23 00:34 UTC] kalle@php.net
-Assigned To: ab +Assigned To: krakjoe
 [2017-10-23 00:34 UTC] kalle@php.net
@joe I think the implementation looks just fine, but as I noted earlier it should probably be located in main/ or ext/standard and use the naming convention we already have inherited, like getnetworkinterfaces() or something in the manner
 [2017-11-23 22:50 UTC] pollita@php.net
-Assigned To: krakjoe +Assigned To: pollita
 [2017-11-23 22:50 UTC] pollita@php.net
With permission from joe and anatol, I've adopted their diff and merged it with my own and produced: https://github.com/php/php-src/pull/2935

Planning to merge it to 7.3 soon, unless internals@ has objections.
 [2017-11-27 15:20 UTC] pollita@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 27 05:01:27 2024 UTC