|
Posted by Sandman on 02/13/07 20:41
I dont think I understand them. I've read the section on scope in the
manual inside out.
I'm running PHP 5.2.0 Here is the code I'm working on:
//include_me.php
<?php
$MYVAR = array();
global $MYVAR, $a;
?>
//array1.php
<?php
require("include_me.php");
global $MYVAR, $a;
$sname = 'user';
$email = 'user@yahoo.com';
$GLOBALS['a'] = 'here';
$MYVAR['sname'] = $sname;
$MYVAR['email'] = $email;
$MYVAR['age'] = 34;
print "SNAME: {$MYVAR['sname']} <br>";
print "EMAIL: {$MYVAR['email']} <br>";
print "AGE: {$MYVAR['age']} <br>";
print "A: $a <br>";
print '<a href="./array2.php">Next</a>';
?>
//array2.php
<?php
require("include_me.php");
global $MYVAR, $a;
$sname = $MYVAR['sname'];
$email = $MYVAR['email'];
print "SNAME: $sname <br>";
print "EMAIL: {$MYVAR['email']} <br>";
print "AGE: {$MYVAR['age']} <br>";
print "A: $a <br>";
?>
When I load array1.php, I see:
SNAME: user
EMAIL: user@yahoo.com
AGE: 34
A: here
Next
Click on Next, and I see:
SNAME:
EMAIL:
AGE:
A:
Can I preserve the changes across page loads with globals?
Thanks,
EL
Navigation:
[Reply to this message]
|