Hướng dẫn public ip php
I need to get local IP of computer like 192.*.... Is this possible with PHP? I need IP address of system running the script, but I do not need the external IP, I need his local network card address. asked Jul 10, 2010 at 12:28 0 From CLIPHP < 5.3.0
PHP >= 5.3.0
answered Nov 5, 2013 at 18:37 andras.timandras.tim 1,8741 gold badge12 silver badges23 bronze badges 9 answered Jul 10, 2010 at 12:30 Sergey EreminSergey Eremin 10.8k2 gold badges37 silver badges44 bronze badges 4 This is an old post, but get it with this:
For example:
Found it on another site, do not remove the trim command because otherwise you will get the computers name. BACKTICKS (The special quotes): It works because PHP will attempt to run whatever it's between those "special quotes" (backticks) as a shell command and returns the resulting output.
Is very similar (but much more efficient) than doing:
answered Sep 10, 2012 at 2:20 CodebeatCodebeat 6,4016 gold badges54 silver badges93 bronze badges 4 A reliable way to get the external IP address of the local machine would be to query the routing table, although we have no direct way to do it in PHP. However we can get the system to do it for us by binding a UDP socket to a public address, and getting its address:
answered Apr 13, 2016 at 16:31 Arnaud Le BlancArnaud Le Blanc 96k22 gold badges201 silver badges193 bronze badges 4 try this (if your server is Linux):
andrewsi 11k132 gold badges34 silver badges49 bronze badges answered Aug 17, 2012 at 11:56 George DeacGeorge Deac 2492 silver badges2 bronze badges 4 Depends what you mean by local: If by local you mean the address of the server/system executing the PHP code, then there are still two avenues to discuss. If PHP is being run through a web server, then you can get the server address by reading If by local you mean the remote address of the website visitor, but not their external IP address (since you specifically said 192.*), then you are out of luck. The whole point of NAT routing is to hide that address. You cannot identify the local addresses of individual computers behind an IP address, but there are some tricks (user agent, possibly mac address) that can help differentiate if there are multiple computers accessing from the same IP. Taz 3,6672 gold badges37 silver badges58 bronze badges answered Jul 10, 2010 at 12:39 FoscoFosco 37.5k6 gold badges84 silver badges100 bronze badges 2 hostname(1)
can tell the IP address: answered May 16, 2013 at 19:50 ern0ern0 3,11024 silver badges35 bronze badges It is very simple and above answers are complicating things. Simply you can get both local and public ip addresses using this method.
answered Apr 6, 2019 at 5:50 1 You may try this as regular user in CLI on Linux host:
Output:
answered Oct 22, 2013 at 10:41 ab1965ab1965 1312 silver badges3 bronze badges 2 You can use this php code :
If you want get ipv4 of your system, Try this :
answered Aug 15, 2021 at 9:46
I tried in Windows pc and Its worked and also think that Will work on Linux to. Yash Parekh 1,5052 gold badges21 silver badges30 bronze badges answered May 4, 2015 at 5:02 Pratik BodaPratik Boda 3942 silver badges6 bronze badges It is easy one. You can get the host name by this simple code.
Or you can also use double-beep 4,57613 gold badges30 silver badges40 bronze badges answered Apr 11, 2019 at 12:32 0
It worked for me. answered Apr 1, 2020 at 22:42 FakhamatiaFakhamatia 8623 gold badges11 silver badges21 bronze badges For Windows:
The $ipa array returns all local IPs of the system answered Jun 26, 2021 at 22:27 P.O.W.P.O.W. 1,6451 gold badge14 silver badges13 bronze badges I fiddled with this question for a server-side php (running from Linux terminal) I exploded 'ifconfig' and trimmed it down to the IP address. Here it is:
And of course change 'wlan0' to your desired network device. My output is:
answered Jan 28, 2014 at 3:47 GonenGonen 3913 silver badges4 bronze badges In windows
answered Dec 3, 2020 at 6:21 If you are in a dev environment on OS X, connected via Wifi:
answered Aug 25, 2016 at 13:33 gpupogpupo 9129 silver badges16 bronze badges To get the public IP of your server:
If none of these global variables are available in your system or if you are in a LAN, you can query an external service to get your public IP:
answered Jun 13 at 0:05 GeorgePGeorgeP 6507 silver badges23 bronze badges
Sirko 70.5k19 gold badges143 silver badges175 bronze badges answered Apr 20, 2013 at 7:34 1 Try this
answered Jul 19, 2012 at 13:54 |