|
Posted by Norman Peelman on 08/30/06 22:15
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:E8WdnQrOCrCsUGjZnZ2dnUVZ_oednZ2d@comcast.com...
> Skybuck wrote:
> >><?php
> >>
> >> switch ($_SERVER['REMOTE_ADDR']) {
> >> case '143.3.5.1':
> >> header('Location: BlueIndex.htm');
> >> break;
> >> case '124.6.15.7':
> >> header('Location: RedIndex.htm');
> >> break;
> >> default:
> >> header('Location: DefaultIndex.htm');
> >> }
> >>?>
> >
> >
> > Hello,
> >
> > Is it possible to use an "or" operator in php ? I only want to specific
> > the location twice, since there are only two versions of the website.
> > However there can be many ip's to include, for example in pseudo code:
> >
> > if (RemoteAddress = '192.5.6.7') or
> > (RemoteAddress = '192.5.6.8') or
> > (RemoteAddress = '192.4.6.8') or
> > (RemoteAddress = '112.44.6.8') then
> > begin
> > header('Location: RedIndex.htm');
> > end else
> > begin
> > header('Location: BlueIndex.htm');
> > end;
> >
> > Is this possible in PHP ?
> >
> > Bye,
> > Skybuck.
> >
>
> Did you try looking this up in the manual?
>
> Yes, it is possible - see
> http://www.php.net/manual/en/language.operators.logical.php.
>
> But your problem is in how your if statement is constructed. See
>
http://www.php.net/manual/en/language.control-structures.php#control-structures.if
>
>
How about 'in_array()'?
$ip_arr = array('192.5.6.7',
'192.5.6.8',
'192.4.6.8',
'112.44.6.8'
);
if (in_array($_SERVER['REMOTE_ADDR'], $ip_arr))
{
header('Location: RedIndex.htm');
}
else
{
header('Location: BlueIndex.htm');
}
.... not sure if you need to use the full domain name in the header function
or not.
Norm
Navigation:
[Reply to this message]
|