473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Idea for PHP Enhancement: register_global s_manual

With all the problems with having register_global s = on, I propose the
following idea:

We define register_global s_manual = on as a new configuration default.

What this does is enable 3 new explicit variable declaration mechanisms
with the same syntax as the existing static and global mechanisms.

They would be httpget, httppost and session, so for example:

httpget $user_id;
httppost $credit_card;
session $really_importa nt_stuff;

Each of these declaration lines would effectively enable
register_global s for one specific variable in one particular method
(GET, POST or session).

Creative suggestions, comments would be welcome.

--
Spam:newsgroup( at)cr*********@ verisign-sux-klj.com
EMail:<01100011 001011100110001 001110101011100 10011010110
110010101000000 011000110111001 001100001011110 10011011100
110000101110010 001011100110001 101101111011011 0100100000>
Jul 17 '05
50 3776
127.0.0.1 <newsgroup(at)c r*********@veri sign-sux-ijlkl.com> wrote:
Phil Roberts wrote:
But what is the POINT of your method when PHP has plenty of non-
register_global s reliant methods already?


It doesn't have one for SESSION variables yet ....


extract($_SESSI ON);

JOn
Jul 17 '05 #21
Jon Kraft wrote:
But what is the POINT of your method when PHP has plenty of non-
register_global s reliant methods already?


It doesn't have one for SESSION variables yet ....


extract($_SESSI ON);


How does that get a session variable 'X' into and out of $X ?

--
Spam:newsgroup( at)cr*********@ verisign-sux-klj.com
EMail:<01100011 001011100110001 001110101011100 10011010110
110010101000000 011000110111001 001100001011110 10011011100
110000101110010 001011100110001 101101111011011 0100100000>
Jul 17 '05 #22
127.0.0.1 <newsgroup(at)c r*********@veri sign-sux-ijlkl.com> wrote:
Jon Kraft wrote:
>> But what is the POINT of your method when PHP has plenty of non-
>> register_global s reliant methods already?
>
> It doesn't have one for SESSION variables yet ....


extract($_SESSI ON);


How does that get a session variable 'X' into and out of $X ?


extract() attempts to create variables (names = keys) from an associative
array.
The advantage of extract() is that it provides a high level of control
through the parameter "extract_ty pe", which a simple register_global
variant wouldn't.

JOn
Jul 17 '05 #23
Jon Kraft wrote:

extract($_SESSI ON);


How does that get a session variable 'X' into and out of $X ?


extract() attempts to create variables (names = keys) from an
associative array.


SO - how does that get session variable 'x' into and out of $x ?

--
Spam:newsgroup( at)cr*********@ verisign-sux-klj.com
EMail:<01100011 001011100110001 001110101011100 10011010110
110010101000000 011000110111001 001100001011110 10011011100
110000101110010 001011100110001 101101111011011 0100100000>
Jul 17 '05 #24
127.0.0.1 <newsgroup(at)c r*********@veri sign-sux-ijlkl.com> wrote:
Jon Kraft wrote:
>>
>> extract($_SESSI ON);
>
> How does that get a session variable 'X' into and out of $X ?


extract() attempts to create variables (names = keys) from an
associative array.


SO - how does that get session variable 'x' into and out of $x ?


Sorry, I don't get your question - if it is a question and not a rhetorical
statement that renders my suggestion useless?

Let's say we have a session variable "x" ($_SESSION['x']).
extract()'s default behaviour would result either in a new variable $x or an
assignment of the value of the session variable "x" to the existing
variable $x. If you assign another value to $x, it is overwritten (again),
which doesn't change the value of the session variable "x" unless you tell
extract() to create the (new) variables by reference (EXTR_REFS,
PHP>=4.3.0).

Please enlighten me if I totally misunderstood what you were after.

JOn
Jul 17 '05 #25
Jon Kraft wrote:
Please enlighten me if I totally misunderstood what you were after.


I'm after the ability to use the variable $x in a script, such that
between requests from the client it retains its value.

That is all.

By variable $x I mean $x, $fred, $user_id, not $_XZJ[14] or anything
else.

--
Spam:newsgroup( at)cr*********@ verisign-sux-klj.com
EMail:<01100011 001011100110001 001110101011100 10011010110
110010101000000 011000110111001 001100001011110 10011011100
110000101110010 001011100110001 101101111011011 0100100000>
Jul 17 '05 #26
127.0.0.1 wrote:
With all the problems with having register_global s = on, I propose the
following idea:

We define register_global s_manual = on as a new configuration default.

What this does is enable 3 new explicit variable declaration mechanisms
with the same syntax as the existing static and global mechanisms.

They would be httpget, httppost and session, so for example:

httpget $user_id;
httppost $credit_card;
session $really_importa nt_stuff;

Each of these declaration lines would effectively enable
register_global s for one specific variable in one particular method
(GET, POST or session).

Creative suggestions, comments would be welcome.


$user_id =& $_GET['user_id'];
$credit_card =& $_POST['credit_card'];
$really_importa nt_stuff =& $_SESSION['really_importa nt_stuff'];

works fine, I use it all the time.

Jul 17 '05 #27
Kevin Thorpe wrote:
$really_importa nt_stuff =& $_SESSION['really_importa nt_stuff'];

works fine, I use it all the time.


So the following would work ?

First Client Request...
session_start() ;
$X =& $_SESSION['X'];
$Y = 'Fred';
$X = $Y;

Second client request...
session_start() ;
$X =& $_SESSION['X'];
$Y = $X;
echo($Y); ... printing 'Fred'....

--
Spam:newsgroup( at)cr*********@ verisign-sux-klj.com
EMail:<01100011 001011100110001 001110101011100 10011010110
110010101000000 011000110111001 001100001011110 10011011100
110000101110010 001011100110001 101101111011011 0100100000>
Jul 17 '05 #28
127.0.0.1 <newsgroup(at)c r*********@veri sign-sux-ijlkl.com> wrote:
Jon Kraft wrote:
Please enlighten me if I totally misunderstood what you were after.


I'm after the ability to use the variable $x in a script, such that
between requests from the client it retains its value.

That is all.

By variable $x I mean $x, $fred, $user_id, not $_XZJ[14] or anything
else.


Check my previous reply (and the manual for extract()) for the extract_type
"EXTR_REFS" .
An assignment of a new value to $x would then in fact change the session
variable "x".

HTH;
JOn
Jul 17 '05 #29
127.0.0.1 wrote:
Kevin Thorpe wrote:
$really_impor tant_stuff =& $_SESSION['really_importa nt_stuff'];

works fine, I use it all the time.


So the following would work ?

First Client Request...
session_start() ;
$X =& $_SESSION['X'];
$Y = 'Fred';
$X = $Y;

Second client request...
session_start() ;
$X =& $_SESSION['X'];
$Y = $X;
echo($Y); ... printing 'Fred'....


Yes, it would (see test script):

<?php
if(!isset($_GET['next'])){
// First Client Request...
session_start() ;
$X =& $_SESSION['X'];
$Y = 'Fred';
$X = $Y;
echo '$_SESSION[\'X\']: ',$_SESSION['X'],'<br>';
echo '$X: ',$X,'<br>';
echo '$Y: ',$Y,'<br>';
echo '<a href="?next">ne xt</a>';
}else{
// Second client request...
session_start() ;
$X =& $_SESSION['X'];
$Y = $X;
echo '$_SESSION[\'X\']: ',$_SESSION['X'],'<br>';
echo '$X: ',$X,'<br>';
echo '$Y: ',$Y,'<br>';
}
?>
--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #30

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

Similar topics

4
1797
by: Dalan | last post by:
I have been using a module for printing labels in Access 97, and although it works fine, I would like to add a small enhancement to it. The module allows for setting the number of labels to print and/or to skip; however, the Cancel command button does not function, nor does clicking the X-close. Clicking either one is the same as clicking the OK button. Since the module creates and displays the dialog box, I will need a piece of code to...
104
7207
by: cody | last post by:
What about an enhancement of foreach loops which allows a syntax like that: foeach(int i in 1..10) { } // forward foeach(int i in 99..2) { } // backwards foeach(char c in 'a'..'z') { } // chars foeach(Color c in Red..Blue) { } // using enums It should work with all integral datatypes. Maybe we can step a bit further: foeach(int i in 1..10, 30..100) { } // from 1 to 10 and 30 to hundred
22
1607
by: WXS | last post by:
Sometimes a method in a class requires the use of class instance variables/fields that will not be used outside of the method itself. Currently this means you must create a instance field in the class such that from a maintenance stand point it is disconnected from the method, and also affords the opportunity for other methods to mess with the variable when they never should. For example: public class MyClass
6
1559
by: WXS | last post by:
I know this sounds contrary to the idea of an interface, but read this and see what you think. ----------------------------------------------------------------------------------------- It would be nice if there was a way for a class to create a special type of interface, a private one. Private meaning it's not directly exposed at the class level, you need to be explicitly handed a reference to it by the class. Often the encapsulation issue...
0
9715
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10603
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
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7643
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
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
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
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
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.