You are here: Re: Including a page w/ GET arguments « PHP Programming Language « IT news, forums, messages
Re: Including a page w/ GET arguments

Posted by Andy Jeffries on 03/14/06 11:30

On Mon, 13 Mar 2006 23:23:40 -0500, Jerry Stuckle wrote:
> The file name is not 'mypage.php?name=joe', is it? That is, do you see
> that in your directory listing?
>
> When you use GET parameters, the web server strips them out before
> fetching the file. include() does not such thing.
>
> Include just copies the included file into the location in your existing
> file, just as if you had cut and pasted it. So, if you have:
>
> $name='joe';
> include('mypage.php');
>
> Within mypage. php you can just reference $name and get 'joe'.

You're probably better off adding name to $_GET so the same code
can work regardless of which way mypage.php is being called (on it's own
or through this page).

$_GET['name'] = 'joe';
include('mypage.php');

Or (just for completeness, it's slower) you could do:

include("http://myhostname/mypage.php?name=joe");

(this involves apache so would register an extra hit on your site and be
slower as it would involve a separate PHP instance).

Cheers,


Andy


--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

 

Navigation:

[Reply to this 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

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