Jump to content

Module talk:IPAddress

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dcoetzee (talk | contribs) at 05:12, 6 March 2013 (+Note that extra whitespace is not permitted (e.g. "127.0.0.1 " with an extra space at the end is not a valid IP address).). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

isIp

Takes a single argument, a string, and returns:

  • "6" if it is a valid IPV6 address
  • "4" if it is a valid IPV6 address
  • empty string if it is neither.

When applied to {{PAGENAME}}, this helps determine whether a template is being placed on an anonymous user page/user talk page or not, as used in Template:AfC talk:

{{#if:{{IsIPAddress|{{PAGENAME}}}}|I'm on an anonymous IP user or user talk page|I'm on some other page}}

Note that extra whitespace is not permitted (e.g. "127.0.0.1 " with an extra space at the end is not a valid IP address).

isIpV6

Returns 1 if the given argument is a valid IPv6 address, else 0.

isIpV4

Returns 1 if the given argument is a valid IPv4 address, else 0.