-2

I got this error

PHP Fatal error: Call-time pass-by-reference has been removed on line 14

<?php

class MyClass
{
    public function Sum($a, $b)
    {
        $sum = $a+$b;
        echo "Sum($a, $b) = $sum";
    }
}


// position [0] is the script's file name
array_shift(&$argv);
$className = array_shift(&$argv);
$funcName = array_shift(&$argv);

echo "Calling '$className::$funcName'...\n";

call_user_func_array(array($className, $funcName), $argv);

?>

and here is what I use in my command line

E:\>php testClass.php MyClass Sum 2 3

as I following this link

What have I done wrong here ? I am new to PHP but trying to slowly learn. Please suggest. Thanks,

Community
  • 1
  • 1
JPC
  • 5,063
  • 20
  • 71
  • 100
  • 1
    Change to `array_shift($argv);` http://php.net/manual/language.references.pass.php – Alexey Chuhrov Sep 21 '16 at 15:37
  • 1
    The ampersand belongs in the function argument list, not in the call argument list. That has been changed years ago, I think when php4 came out... – arkascha Sep 21 '16 at 15:38

1 Answers1

1

You don't need &$argv but $argv in all of your line.

Gectou4
  • 219
  • 1
  • 5