Re: menu andfolder question
| From: | chris smith | Date: | Sat, 05 Jan 2008 11:43:00 +0000 |
| Subject: | Re: menu andfolder question | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-266772@lists.php.net to get a copy of this message | ||
On Jan 5, 2008 10:36 PM, Alain Roger <raf.news@gmail.com> wrote:
> ok, maybe i did not write my question well.
> i already used it because i setup the DirectoryIndex to index.php,
> index.html
>
> my concern for now, how to have the same behavior on my local computer
> (development computer) ?
> my computer has IP 200.170.1.2 (for example)
> so in my brower i type : 200.170.1.2/myWebSite
>
> this load my firt index.php webpage to browser... if i pass my mouse cursor
> over menu link "Company", it displays
> http://200.170.1.2/myWebSite/200.170.1.2/company
> which is not great :-(
>
> here is the code i use :
> print "<div class='MenuItem4'><a
>
> href='".$_SERVER['SERVER_NAME']."/company'>Company</a></div>";
In your case it's taking the existing url and tacking the rest on
which is not what you want.
If you print out $_SERVER['SERVER_NAME'] - it doesn't include the
http[s]:// at the start to make it a complete absolute url. It also
doesn't include your current directory (myWebSite) so even with
http:// at the start you'd end up with http://ip.address/company - not
what you want either.
You should probably have a variable or define for your application url
in your config file so you can:
print "<a href='" . APPLICATION_URL .
"/company'>Company</a>";
It's much safer this way than relying on any $_SERVER variables (which
believe it or not are suspect to XSS attacks/vulnerabilities).
--
Postgresql & php tutorials
http://www.designmagick.com/