Reply to Re: PHP Beginner question

Your name:

Reply:


Posted by David Haynes on 05/31/06 09:50

Toby Inkster wrote:
> David Haynes wrote:
>
>> <?php
>> /**
>> * Module: redirect.inc
>> *
>> * Manages a redirection when there may be a session active.
>> * Also correctly re-addresses URLs that are not absolute.
>> *
>> * @param string $url
>> */
>> function redirect($url) {
>> session_write_close();
>>
>> if( substr($url, 0, 4) != 'http' ) {
>> if( isset($_SERVER['HTTP_HOST']) ) {
>> $url = 'http://'.$_SERVER['HTTP_HOST'].$url;
>> } else {
>> $url = 'http://localhost'.$url;
>> }
>> }
>>
>> header("location: $url");
>> exit;
>> }
>> ?>
>
> redirect("http_1.1_spec.html");
>
> :-)

I use a convention that all urls in redirect must either be absolute or
start with /, but I see your point. substr($url, 0, 5) != 'http:' would
be better.

Thanks!
-david-

[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

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