473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to add (or emulate) a new superglobal

This is just for curiosity, but:

Lets say I would like to have a new superglobal, in addition to
automatically made get, post, cookie and session.

I mean, I would (theoretically) want to AVOID doing

function ()
{
global $config;
....
}

and just be able to use $config in functions and classes.
Not that it would be the nicest practise though. But let's say for the sake
of fun or doing it.

Is there a way? Of course you could reset, set and reset again some session
variable, but that would not be very nice way.

Feb 7 '07 #1
3 1703
P Pulkkinen wrote:
This is just for curiosity, but:

Lets say I would like to have a new superglobal, in addition to
automatically made get, post, cookie and session.

I mean, I would (theoretically) want to AVOID doing

function ()
{
global $config;
....
}

and just be able to use $config in functions and classes.
Not that it would be the nicest practise though. But let's say for the
sake of fun or doing it.

Is there a way? Of course you could reset, set and reset again some
session variable, but that would not be very nice way.
Why not simply throw your stuff in $GLOBALS?

Something like this:
$myVars = array('nr1' =123, 'nr2' ="bla");
$GLOBALS[] = $myVars;

It should have the same effect. I think.

Regards,
Erwin Moller
Feb 7 '07 #2
Why not simply throw your stuff in $GLOBALS?
Something like this:
$myVars = array('nr1' =123, 'nr2' ="bla");
$GLOBALS[] = $myVars;
It should have the same effect. I think.
Regards,
Erwin Moller
Well, I have not tried. I hope it works. I thought $GLOBALS, or was it
$_GLOBALS, was only reserved for php inner automatic use.
Feb 7 '07 #3
P Pulkkinen wrote:
>Why not simply throw your stuff in $GLOBALS?
Something like this:
$myVars = array('nr1' =123, 'nr2' ="bla");
$GLOBALS[] = $myVars;
It should have the same effect. I think.
Regards,
Erwin Moller

Well, I have not tried. I hope it works. I thought $GLOBALS, or was it
$_GLOBALS, was only reserved for php inner automatic use.
Yes, I asked in the very newsgroup a week ago how to throw out all variables
in PHP.
I tried print_r($_GLOBALS), but it turned out the developers named it in
their infinite wisdom $GLOBALS without the _.

Regards,
Erwin Moller
Feb 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rainer Erismann | last post by:
Hi, i have a variable (well, an Object) which is needed in beneath every Script. it's not needed to be changed during the whole script, so i like to access it easyli without passing by or declare...
1
by: pkp | last post by:
Does anyone know a way I can register my own superglobal? Meaning, I would like to make my own variable such as $_SESSION which is available in all scopes and contexts without having to declare...
2
by: bulk88 | last post by:
How can I emulate DOM level 1 removeChild in IE 4? I already figured out to emulate getElementById by doing this if((!document.getElementById) && document.all) {document.getElementById =...
9
by: Super Mango | last post by:
Hi - Is it possible to change the status of a variable to superglobal so it'll be valid inside functions without declaring it with "global" inside each function? Thanks -
61
by: /* frank */ | last post by:
I have to do a homework: make a CPU simulator using C language. I have a set of asm instructions so I have to write a program that should: - load .asm file - view .asm file - do a step by step...
5
by: splodge | last post by:
This may seem like a stupid question but I want to check before I go ahead and build this... I am working on a portal, part of which allows users to upload files. Part of the array within...
3
by: Michaelp | last post by:
Hello! I see that I can access a superglobal element using the index this way: print("<p>$_GET</p>"); //(element index without any delimiters within a double-quotation-mark-delimited string)...
3
by: Phper | last post by:
Can anyone give a definition of it?
14
by: Eugeny Myunster | last post by:
Hello all, How can i emulate sizeof() only for integers?
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.