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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.