Reply to Re: Issue with PHP and hard coded site name

Your name:

Reply:


Posted by J.O. Aho on 03/21/06 01:22

L C wrote:
> Hello,
>
> I am trying to update a web page we have, not a web person so I apologize in
> advance. When I try to use Dreamweaver to work on it I end up going to our
> public site. It seems as though the site name is "hardcoded" in a php file.
> I have included the code of the pages that call each other - Index.html ->
> index.php -> dopage.php. In the dopage.pgp page you will see that
> $publicaddress is mapped to our site (site name changed for this posting).
>
> My question is: How do I get around that so I can test my edits without
> going to the web?

There are a couple of options here,

The fast one:

1. Open a terminal (dos prompt)
2. CD to the directory where the main script is located
3. execute the script with php (php.exe index.php)


The more complicated way:

1. Setup a webserver+php (run it only on 127.0.0.1)
2. place the scripts in a "public" location
3. access the page in questuon (http://127.0.0.1/index.php)
(easy way to make this, is to install linux or bsd)



> $publicAddress = 'http://www.publicsite.com/';

IMHO this is better:
$publicAddress= 'http://' . $_SERVER['SERVER_NAME'];

Then you don't have to change anything, the script will know the location from
the server. There are quite many useful globals to use, see
http://www.php.net/manual/en/reserved.variables.php


//Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация