Re: Passing variables between pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2008-09-21 at 20:39 +0100, Stut wrote:
> On 21 Sep 2008, at 18:13, Nathan Rixham wrote:
> > tedd wrote:
> >> At 8:31 PM +0100 9/20/08, Nathan Rixham wrote:
> >>> Am I missing something here..?
> >> Yes. You are missing the point.
> >>> This is exactly the same; you don't need $_SESSION's in this case  
> >>> because all you're doing is POST'ing the data every time..
> >> And that's what you are missing -- it's not continued POSTing!
> >> Follow closely,
> >> http://www.webbytedd.com/bb/php-run-php/
> >> While I'm using a Submit Post button to go from this script to the  
> >> next script I am NOT sending any data via the POST. To prove it,  
> >> use FF and see what's passed.
> >> All data is passed/available to the next script because the next  
> >> script is an include.
> >> For example, this parent script has the variable:
> >> $test = "This is a test";
> >> And the next script (either a.php, or b.php, or c.php -- your  
> >> choice) simply echo's $test.
> >> Please note, the contents of the variable $test was NOT passed via  
> >> a POST, but rather retained because the parent script included the  
> >> next script.
> >> Do you see the difference?
> >> Here's another example presenting the same technique in a different  
> >> way:
> >> http://www.webbytedd.com/bb/tedd/index.php
> >> All the variables remain intact AND there is nothing in the  
> >> REQUEST, SESSION nor COOKIE arrays.
> >> I have a hard time trying to get people to understand this simple  
> >> concept. It's so simple that people often overlook how powerful it  
> >> is.
> >> For example, with a little forethought, I think there isn't a  
> >> script I've written that I could not have used this technique and  
> >> dispensed with SESSION's all together. That's pretty powerful,  
> >> don't you think?
> >> Do you understand what I'm doing now?
> >>> no ill-intention meant.
> >> That's Okay -- I realize you meant no ill-intent.
> >> Neither do I -- I realize that occasionally simple concepts are  
> >> hard for you smarter guys to get because you have to dumb down a  
> >> lot to consider what we're talking about. But I think it's an  
> >> interesting concept to consider.
> >> Cheers,
> >> tedd
> >
> >
> > at it's simplest is this correct..?
> >
> > index.php
> > <?php
> > $variables = $_POST;
> > include 'anotherscript.php';
> > ?>
> >
> > anotherscript.php
> > <?php
> > print_r( $variables ); //include has access to $variables from parent
> > print_r( $_POST ); //include has access to post data as well
> > ?>
> >
> > I'm struggling to follow here I thinks! lol
> 
> I don't think you're missing the point Nathan, I think you've hit it  
> on the head. This technique does not solve the problem of passing  
> variables between requests. I think the only benefit here is to avoid  
> having to repost data by including the next script rather than  
> bouncing off the browser.
> 
> Or maybe I'm missing the point.

Looks like a basic front-end loader pattern. Data isn't passed, it's
available by virtue of being in the current request's context.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux