I want to check via php if someone connects to my site via IPv4 or IPv6.
The client address can be found in $_SERVER[\"REMOTE_ADDR\"] but
$_SERVER[\"REMOTE_ADDR\"]
You can use AF_INET6 to detect if PHP is compiled with IPv6 support:
AF_INET6