Gian Santillan
Gian Santillan

Reputation: 773

How to set wildcard in $_SERVER['REMOTE_ADDR'] possible?

is it possible to set $_SERVER['REMOTE_ADDR'] to a wildcard, so that anyone on the network can see this?

<?php


if($_SERVER['REMOTE_ADDR'] == "112.200.150.212"){

                ?>
                <a href="http://www.tinycounter.com" target="_blank" title="free hit counter"><img border="0" alt="free hit counter" src="http://mycounter.tinycounter.com/index.php?user=fortressgate"></a>

                <?php
                }?>

but i want the network can see the counter... so it would look like this?

if($_SERVER['REMOTE_ADDR'] == "112.200.150.%")

is this possible?

Upvotes: 0

Views: 4693

Answers (2)

bimbom22
bimbom22

Reputation: 4510

if(strpos($_SERVER['REMOTE_ADDR'], "112.200.150.") === 0)

Upvotes: 2

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324750

Two solutions:

$chk = "112.200.150.";
if( substr($_SERVER['REMOTE_ADDR'],0,strlen($chk)) == $chk)

OR:

if( preg_match("(^112\.200\.150\.)",$_SERVER['REMOTE_ADDR']))

Upvotes: 5

Related Questions