[PHP] Creating custom superglobals

2006-08-14 Thread Ville Mattila

Hello,

Does the PHP environment (5.1.4) provide a way to define some custom 
variables as a superglobal? It would be useful for saving certain site 
preferences and settings that must be referred in many variables and 
classes, without every time writing global keyword at the beginning of a 
function definition.


Thanks,
Ville

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Creating custom superglobals

2006-08-14 Thread Jay Blanchard
[snip]
Does the PHP environment (5.1.4) provide a way to define some custom 
variables as a superglobal? It would be useful for saving certain site 
preferences and settings that must be referred in many variables and 
classes, without every time writing global keyword at the beginning of a

function definition.
[/snip]

An include file? 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating custom superglobals

2006-08-14 Thread Stut

Ville Mattila wrote:
Does the PHP environment (5.1.4) provide a way to define some custom 
variables as a superglobal? It would be useful for saving certain site 
preferences and settings that must be referred in many variables and 
classes, without every time writing global keyword at the beginning of 
a function definition.


No, PHP does not allow userland to create superglobals. However, all 
global variables can be accessed through the $GLOBALS superglobal.


-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Creating custom superglobals

2006-08-14 Thread KermodeBear
Hello,

You CAN create custom superglobals, but it requires that you have RunKit
enabled: http://us3.php.net/runkit

HTH,
K. Bear

 -Original Message-
 From: Stut [mailto:[EMAIL PROTECTED] 
 Sent: Monday, August 14, 2006 10:04 AM
 To: Ville Mattila
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Creating custom superglobals
 
 Ville Mattila wrote:
  Does the PHP environment (5.1.4) provide a way to define 
 some custom 
  variables as a superglobal? It would be useful for saving 
 certain site 
  preferences and settings that must be referred in many 
 variables and 
  classes, without every time writing global keyword at the 
 beginning of 
  a function definition.
 
 No, PHP does not allow userland to create superglobals. 
 However, all global variables can be accessed through the 
 $GLOBALS superglobal.
 
 -Stut
 
 --
 PHP General Mailing List (http://www.php.net/) To 
 unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Creating custom superglobals

2006-08-14 Thread Robert Cummings
On Mon, 2006-08-14 at 10:45 -0400, KermodeBear wrote:
 Hello,
 
 You CAN create custom superglobals, but it requires that you have RunKit
 enabled: http://us3.php.net/runkit

Which will make your application incompatible with any distribution
where runkit is not enabled :/ Which kinda sucks, I wish more stuff was
part of the core.

Cheers,
Rob.

 
 HTH,
 K. Bear
 
  -Original Message-
  From: Stut [mailto:[EMAIL PROTECTED] 
  Sent: Monday, August 14, 2006 10:04 AM
  To: Ville Mattila
  Cc: php-general@lists.php.net
  Subject: Re: [PHP] Creating custom superglobals
  
  Ville Mattila wrote:
   Does the PHP environment (5.1.4) provide a way to define 
  some custom 
   variables as a superglobal? It would be useful for saving 
  certain site 
   preferences and settings that must be referred in many 
  variables and 
   classes, without every time writing global keyword at the 
  beginning of 
   a function definition.
  
  No, PHP does not allow userland to create superglobals. 
  However, all global variables can be accessed through the 
  $GLOBALS superglobal.
  
  -Stut
  
  --
  PHP General Mailing List (http://www.php.net/) To 
  unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
 
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating custom superglobals

2006-08-14 Thread Adam Zey

Robert Cummings wrote:

Which will make your application incompatible with any distribution
where runkit is not enabled :/ Which kinda sucks, I wish more stuff was
part of the core.

Cheers,
Rob.



I agree, this module looks very powerful. The ability to write wrappers 
around internal functions by renaming the existing functions could come 
in very handy, and defining new superglobals would help make code more 
readable (IE, $settings['foo'] rather than $GLOBALS['settings']['foo']). 
Heck, even runkit_lint_file would be somewhat helpful, since it's save 
us from having to make a shell call for syntax checking.


Regards, Adam.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating custom superglobals

2006-08-14 Thread Richard Lynch
On Mon, August 14, 2006 8:40 am, Ville Mattila wrote:
 Does the PHP environment (5.1.4) provide a way to define some custom
 variables as a superglobal? It would be useful for saving certain site
 preferences and settings that must be referred in many variables and
 classes, without every time writing global keyword at the beginning of
 a
 function definition.

Not unless you want to install the RunKit extension, which pretty much
lets you re-define ANYTHING in PHP...

Probably a Bad Idea...

$_SESSION might be a reasonable place to store your data, however,
depending on what it is...

Maybe I'm mis-understanding what you are storing, but it seems like
the kind of stuff that belongs in $_SESSION...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating custom superglobals

2006-08-14 Thread Dave Goodchild

On 15/08/06, Richard Lynch [EMAIL PROTECTED] wrote:


On Mon, August 14, 2006 8:40 am, Ville Mattila wrote:
 Does the PHP environment (5.1.4) provide a way to define some custom
 variables as a superglobal? It would be useful for saving certain site
 preferences and settings that must be referred in many variables and
 classes, without every time writing global keyword at the beginning of
 a
 function definition.

...or why not keep it simple and use include_once/require_once? I
generally have a config file for every app that contains constants,
variables and so on that are used across the application.