473,804 Members | 3,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Register SuperGlobal

pkp
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 it
with a global.

Example:

global $testVar;
$testVar = 1;
test();

function test(){
echo $testVar;
}

This would print "", I want to be able to
register_superg lobal('testVar' ) and have the function print out "1"...

Any ideas?

Thanks!

Jul 17 '05 #1
1 2136
pkp wrote:
Does anyone know a way I can register my own superglobal?
By writig a PHP extension.
global $testVar;
$testVar = 1;
test();

function test(){
echo $testVar;
}

This would print "", I want to be able to
register_superg lobal('testVar' ) and have the function print out "1"...

Any ideas?


No. Of course you still can use $GLOBALS

$testVar = 1;
test();

function test(){
echo $GLOBALS['testVar'];
}

Regards,
Matthias
Jul 17 '05 #2

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

Similar topics

7
3960
by: Paul Liversidge | last post by:
I'd like your opinions as to why I don't use something like this... A function that iterates through $_GET, $_POST, $_COOKIES and $_SESSION arrays and turn them back into conventional variables. I already have chunks of code at the top of some pages, particularly large forms that look something like this... $id = isset ($_GET) ? $_GET : ""; ....one line after another pulling the variable back from the array and
1
3197
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 it as global in every function. afaik it isnt possible to set a variable to superglobal. Is there any reason why i shouldn't add it to the _SERVER array or any other superglobal? Thanks
1
4581
by: Manu J | last post by:
Hi, i have a login script which makes use of sessions. Login script *********** session_start() ..... ..... ....
1
14158
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of uninitialized value in concatenation (.) at register.pl line 38, <STDIN> line 10." The PERL code is as follows:
9
5749
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 -
5
3006
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 $_FILES superglobal gives the mime type for the file. Is this 100% reliable / accurate? If the mime type says the file type is jpeg is it always right? Two reasons I want to know: 1. Certain types of files mustn't be uploaded, .exe files for example....
3
1724
by: P Pulkkinen | last post by:
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;
3
1584
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) But not this way:
3
2971
by: Phper | last post by:
Can anyone give a definition of it?
0
9575
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10564
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10073
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.