Jump to content

How to avoid using "allow_call_time_pass_reference"


darkninja_com

Recommended Posts

This text is taken from the file php.ini

[color=brown]; Whether to enable the ability to force arguments to be passed by reference
; at function call time.  This method is deprecated and is likely to be
; unsupported in future versions of PHP/Zend.  The encouraged method of
; specifying which arguments should be passed by reference is in the function
; declaration.  You're encouraged to try and turn this option Off and make
; sure your scripts work properly with it in order to ensure they will work
; with future versions of the language (you will receive a warning each time
; you use this feature, and the argument will be passed by value instead of by
; reference).
allow_call_time_pass_reference = Off[/color]

Many of mine scripts don't work when this option turned off. Those that send variable through forms or links. How can I process with form Posted data without this turning on?

Thank you for reading, please help
The PHP community is trying to stop people passing by reference like this:

function myFunc ($arg) {}
$myVar = 'a value';
myFunc(&$myVar);

The above will work if you have allow_call_time_pass_reference = on.

The proper approach now is to define that a variable should be passed by reference right in the function argument declaration like so:

function myFunc (&$arg) {}  // declare pass by reference for $arg
$myVar = 'a value';
myFunc($myVar);  // don't use "&" when calling function

The above will work with allow_call_time_pass_reference = off

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.