Fatal error: Function name must be a string in.. PHP error

前端 未结 3 565
旧巷少年郎
旧巷少年郎 2021-01-14 00:15

Hi I have a class called User and a method called insertUser().

function insertUser($first_name, $last_name, $user_name, $password, $email_address, $group_ho         


        
3条回答
  •  长发绾君心
    2021-01-14 01:01

    Just for the next newbie, another example of how this error

    " PHP Fatal error: Function name must be a string in ..."

    is triggered / and solved is as below;

    Say you have an associative array;

    $someArray = array ( 
                     "Index1" => "Value1",
                     "Index2" => "Value2",
                     "Index3" => "Value3"
                  );
    
    echo $someArray('Index1'); // triggers a fatal  error as above
    

    Solution:

    echo $someArray['Index1']; // <- square brackets - all good now
    

提交回复
热议问题