Satch3000
Satch3000

Reputation: 49384

PHP Function name must be a string error on new variable

I am getting the error:

Function name must be a string on this code:

$profile_data = $user_data('first_name','last_name','email');

Any ideas why this could be?

Upvotes: 1

Views: 8768

Answers (2)

Dilip Godhani
Dilip Godhani

Reputation: 2174

in php function define following

$profileData =  user_date('first_name','last_name','email');



function user_date($first_name,$last_name,$email){
}

Upvotes: 0

newfurniturey
newfurniturey

Reputation: 38436

While you can use variables as function-names, to do so requires the variable to be a string.

The variable $user_data sounds more like an array, or even possibly an object. If this is true, you will receive the error specified. Per the comment from @Jon, it could also be possible that user_data() is a method and the $ is a typo.

If none-of-the-above helps, please all relevant code, specifically the creation of the $user_data variable (or a var_dump($user_data) output).

Upvotes: 5

Related Questions