How to get the IP address used by web-server from a command line script?

I am running a command line script like this, php /path/to/script.php, on a PC where also a web-server is running.

How can I know the address, bound to that web-server, when running a command line PHP script (completely unrelated to that web-server)?

Why am I doing this? I need to run a PHP websocket handler and bind it to the same address that web-server is using.


Are there any PHP specific variable(s) or function(s) that return the address that the server is using, that are accessible to a server side PHP script?