Getting the origin IP and Port of a client
The correct answer for those with minimal networking knowledge
Completing the @marcolz answer with an explicative text.
TL;DR - echo $_SERVER['REMOTE_ADDR'] . ":" . $_SERVER['REMOTE_PORT'];
The meaning behind it:
As everyone should know, it's important to have data about each requisition your clients did, logging their access data for at least five years to come for self protection in case of a legal dispute over copyrights or anything else your users might get themselves into.
The IPv4 world is made of ASN (Autonomous System Number) owners and those who they share their identity with, the so called final user.
As IPv4 has become scarce, most ISPs (Internet Service Providors) provide access to the World Wide Web through very big and huge NAT (Network Address Transtation) called CG-NAT (Carrier Grade Network Address Translation) for those clients who didn't pay enough to be worth a public IPv4 block for themselves, basically all the final user's connections are made through this and the only way to know who was the smartass when something happen is by knowing not only their IP address, but also the port they used on the request.
If you are using PHP on your application you can protect yourself by logging the request origin IP and port.
To do so you can use the following code:
echo $_SERVER['REMOTE_ADDR'] . ":" . $_SERVER['REMOTE_PORT'];
Here we concatenate the request origin IP address and port with a colon in the middle, echoing them in order to see the result.
You can check the veracity of the information by doing the request while listening on tcpdump, if the port used in the request on tcpdump is the same as the one your browser shows then everything worked as expected.
Cheers from the outerworld!