[php] Call-time pass-by-reference has been removed

Possible Duplicate:
Call-time pass-by-reference has been deprecated

While it may be documented somewhere on the internet, I cannot find a solution to my problem. Since the PHP 5.4 update, pass-by-references have been removed.

Now I have a problem with this section of code, and I hope somebody can see what I'm trying to do with it so that they can possibly help me with a solution to overcome my pass-by-reference problem.

Below is the code in question:

public function trigger_hooks( $command, &$client, $input ) {
    if( isset( $this->hooks[$command] ) ) {
        foreach( $this->hooks[$command] as $func ) {
            PS3socket::debug( 'Triggering Hook \'' . $func . '\' for \'' . $command . '\'' );
            $continue = call_user_func( $func, &$this, &$client, $input );
            if( $continue === FALSE ) {
                break;
            }
        }
    }
}

.

This question is related to php class function pass-by-reference public

The answer is


Only call time pass-by-reference is removed. So change:

call_user_func($func, &$this, &$client ...

To this:

call_user_func($func, $this, $client ...

&$this should never be needed after PHP4 anyway period.

If you absolutely need $client to be passed by reference, update the function ($func) signature instead (function func(&$client) {)


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to class

String method cannot be found in a main class method Class constructor type in typescript? ReactJS - Call One Component Method From Another Component How do I declare a model class in my Angular 2 component using TypeScript? When to use Interface and Model in TypeScript / Angular Swift Error: Editor placeholder in source file Declaring static constants in ES6 classes? Creating a static class with no instances In R, dealing with Error: ggplot2 doesn't know how to deal with data of class numeric Static vs class functions/variables in Swift classes?

Examples related to function

$http.get(...).success is not a function Function to calculate R2 (R-squared) in R How to Call a Function inside a Render in React/Jsx How does Python return multiple values from a function? Default optional parameter in Swift function How to have multiple conditions for one if statement in python Uncaught TypeError: .indexOf is not a function Proper use of const for defining functions in JavaScript Run php function on button click includes() not working in all browsers

Examples related to pass-by-reference

Passing an integer by reference in Python Does JavaScript pass by reference? Object passed as parameter to another class, by value or reference? change values in array when doing foreach Call-time pass-by-reference has been removed C++ pass an array by reference Passing Objects By Reference or Value in C# Pass variables by reference in JavaScript JavaScript by reference vs. by value How to do the equivalent of pass by reference for primitives in Java

Examples related to public

How to declare Global Variables in Excel VBA to be visible across the Workbook C# Foreach statement does not contain public definition for GetEnumerator Call-time pass-by-reference has been removed Is it possible to declare a public variable in vba and assign a default value? What is the difference between public, private, and protected? Setting public class variables What is the difference between public, protected, package-private and private in Java?