Results 1 to 2 of 2
Jul 7, 2012, 16:22 #1
- Join Date
- Jul 2012
- 0 Post(s)
- 0 Thread(s)
Relationship of variables between php files
I'm curious as to how variables move in php. If a variable is created in a template then $_POST'ed back to the controller which then put's that variable in a file called $variable which is then sent to another template to display some info then sent back again to the controller for deletion.
Must I always re'$_POST my variables between .php files?
Jul 7, 2012, 23:56 #2
- Join Date
- Jul 2005
- West Springfield, Massachusetts
- 187 Post(s)
- 2 Thread(s)
Hi ellypho, welcome to the forums,
Always? Not at all.
But it's perhaps the most common and easiest way to pass variables, depending.
$_GET if trivial and there aren't many
Cookies if trivial and there aren't many
$_SESSION is another common way but a little trickier until you get used using to them
INSERT into a database table, more over-head and probably only if you want to save across sessions
File Write (eg. XML CSV), more over-head and probably only if you want to save across sessions
IMHO except for $_GET the other ways will be more verbose code.
Or maybe you could write things so there is no need to pass, but include instead?