For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > August 2004 > Newbie Question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Newbie Question
GrImBlY

2004-08-29, 8:55 am

Hi everyone,

I have a technical question which I hope you can help me with.

Basically I'm developing a site and have decided that using Dreamweaver's
Templates is a pain in the arse and I'm using an 'Include' instead which
works like a charm.

However, it works fine on my testing server, but not on the remote server as
the Include comes up with an error if I try Include without a full URL. I've
managed to get it to work by using

Include ('http:\\www.myurllocation.com\thefilename.txt');

But it's really annoying to have to change the header and footer of each
..php file before I upload them. Is there a way of using PHP to detect if
it's on the testing server or remote server ?

Basically I'd like something like this

If Server=Local
{
Include ('file.txt');
}
Else
{
Include ('http:\\www.mysiteurl.com\file.txt');
}
EndIf

Can anyone help ?

Thanks in advance.



GrImBlY

2004-08-29, 8:55 am

Stupid me...

Just did a PHPINFO();

and looked at the system variables produced...

Came up with this:

<?php


if ($_SERVER['SERVER_NAME']!='localhost')

{
$Location='Remote';
}


else
{
$Location='Testing';
}

Echo"$Location";

?>

Which seems to work..



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com