Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Matthew Carter Newsgroups: comp.lang.php Subject: Re: PHP Global Variable Usage - Possible? Date: Sun, 26 Jul 2015 21:42:10 -0400 Organization: Ahungry (http://ahungry.com) Lines: 38 Message-ID: <87k2tmcr65.fsf@ahungry.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="7c986cd4736462de309a749b207746fe"; logging-data="5845"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Pl13pmwdFsJUfzeV1emnl" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:yZ5ml29K7LG+SGZcX4dpigz9NDk= sha1:yyUySUOy66AsLXgWSsRUY55tGDg= Xref: csiph.com comp.lang.php:15613 MikeCopeland writes: > Almost new to PHP, and I'm wondering if PHP will do something I want > to do. Scenario: > 1. 3 Web pages: index.php; text01.php; and people.php > 2. In index.php I want to establish a default value in a global > variable, and I want to access that variable's value in test01.php > 3. In text01.php I have numerous divs and paragraphs of text. I want > to use the global value to establish a default text color and div > background. I also have anchor links in the code to allow other pages > to link to specific areas of the text data in text01.php > 4. In people.php I have some hrefs that link in text01.php. When > someone clicks on those links in people.php, not only do I want > text01.php rendered, but I want to be able to change the global > variable's value so that the logic in text01.php can change > characteristics of that div code in text01.php. > (Note that I have the fundamentals of the Web site working - as .html > pages - and I haven't yet invested in converting to using php sources. > (I did some php Web development several years ago, but I've discarded > that system and forgotten all of what I did: I'm starting over, and I > never did anything like this current project...) > Is such processing at all possible? If so, please direct me to some > examples of "how to" that I may start from. TIA > > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > Variables only persist for the duration of script/program execution. You may want to look into using cookies or sessions (or you could have some persistence via the query string). -- Matthew Carter (m@ahungry.com) http://ahungry.com