Re: How to path global object
| From: | Jason Wong | Date: | Wed, 17 Nov 2004 05:29:43 +0000 |
| Subject: | Re: How to path global object | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-202273@lists.php.net to get a copy of this message | ||
On Wednesday 17 November 2004 00:01, Hongwei Li wrote:
> no values are displayed. Apparently, $obj is not pathed to tsnext.php and
> tsshow.php (the second time), but $ind is. What is wrong in the above
> codes? Can somebody help me?
You seem to have a fundamental misunderstanding of what the keyword 'global'
does. Read
manual > Variables > Variable scope
study and *understand* the examples.
Now the reason why $ind seems to be passed onto tsnext.php is that:
1) global $ind defines a new variable that has a 'value' of NULL
2) $ind++ implicitly converts $ind to 0 (zero) then increments it
3) hence echo $ind shows 1
Summary: if you want to pass values from one page to another either do so
using the URL, or by storing them in sessions.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
In war it is not men, but the man who counts.
-- Napoleon
*/