473,385 Members | 1,934 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,385 software developers and data experts.

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_superglobal('testVar') and have the function print out "1"...

Any ideas?

Thanks!

Jul 17 '05 #1
1 2108
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_superglobal('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
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....
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: Manu J | last post by:
Hi, i have a login script which makes use of sessions. Login script *********** session_start() ..... ..... ....
1
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...
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 -
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: 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...
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?
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.