Re: Defining own globals

From: Date: Wed, 14 Jan 2004 13:08:29 +0000
Subject: Re: Defining own globals
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-174539@lists.php.net to get a copy of this message
From: "Ville Mattila" <ville.mattila@pilotmedia.fi> > Would it be possible to make all hard-coded variables beginning with $_ > automatically global? I've found useful to set some variables per page > to $_PAGE variable (for example $_PAGE['title'] etc) that would be nice > to get available to all functions without extra procedures (like global > command). The best way could be that $_ variables can't be defined by > any user-input (forms, cookies etc)... > > Well, that's a explanation. I hope that someone would give any hint > concerning this subject. :) You already have $GLOBALS as a global (scope wise) variable, just add to that if you want. $GLOBALS['page_title'] = 'etc'; Or you can add directly to $_GET, $_POST, etc, so long as it doesn't interfere with your forms. Maybe you need to use $_SESSION. Bottom line, the variables are already there, just use them. ---John Holmes...

« previous php.general (#174539) next »