You are here: Re: include a file with parameters « PHP Programming Language « IT news, forums, messages
Re: include a file with parameters

Posted by luke on 11/15/22 11:22

> > > What i want to do is the following:
> > >
> > > include (pagecalled.php?argument1=x&argument2=x ..... );
> > >
> >
> > How about this:
> >
> > $argument1 = x;
> > $argument2 = x;
> > include('pagecalled.php');
> >
> > --
> > http://www.phpforums.nl
>
>
> Will pagecalled.php "see" both $argument1 and $argument2? How?
> If so, why do we use this way: pagecalled.php?argument1=x&argument2=x?
> Is it just an option to do the same?

It will 'see' the variables the same way any code written after those
variables were declared could see them - a PHP 'include('');' takes the file
and mixes it in, almost like a copy and paste job of the file contents. Give
it a go, you'll notice it works.

Appending variables onto the URL is a method of sending variables across
pages, it is called 'GET' and another method is called 'POST' - have a read
at php.net.

To demonstrate GET, try this code by itself:

<?php echo $_GET['arg']; ?>

Now view the webpage and append ?arg=hello onto the end of the URL. You can
change arg to equal anything and it will display on the page.

Usually you wouldn't use GET unless you needed to, because the whole world
can see your variables in the address bar, and therefor can reassign them by
editing the URL. This opens your PHP script up to manipulation. However GET
is still pretty handy for times when you want to send variables to another
page through, say, a link, since POST only works through an HTML form. A
whole row of links like <a href=nextpage.php?arg=hello>Say Hello</a> but
with different values for 'arg' - you've only made 1 PHP file called
nextpage.php, but if it's recieving a $_GET['arg'] value you've got an
almost limitless amount of different permutations for that page (dynamic).

Luke

 

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

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