user381800
user381800

Reputation:

PHP Warnings, is this normal?

I am having these warnings in my code despite that it works so was wondering if I am not writing these code properly or something. Have a look.

$image_size = getimagesize($data[$module['_attr']['id']]); <-- works but gives warning (Filename cannot be empty)

echo call_user_func($module['_attr']['type'],$module); <-- works but gives warning (First argument is expected to be a valid callback)

So I am drawing to a conclusion that it doesn't like variables passed in or array elements. Or am I doing something wrong?

Thanks!

Upvotes: 0

Views: 105

Answers (2)

Marcelo Assis
Marcelo Assis

Reputation: 5214

Are you sure your script is working?

I think the first error is because you aren't passing a image path to that function.

The 2nd, is because the first argument MUST be a function. Is $module['_attr']['type'] a function?

Are you debugging those variables?

Upvotes: 0

Pascal MARTIN
Pascal MARTIN

Reputation: 401182

I'm guessing $data[$module['_attr']['id']] is empty (it doesn't contain a path to any file) -- which would explain the first warning.

And $module['_attr']['type'] probably doesn't contain a valid function name -- which would explain the second warning.


Try using something like this to know what's really in $module and $data :

var_dump($module, $data);


Notes :

  • Those warnings indicate your code doesn't work : it doesn't do what you want it to do -- probabaly doesn't do much, considering the warnings.
  • But warnings are not Fatal Error : the execution of the script continues ; even if there is some problem -- which could lead to troubles later.

Upvotes: 2

Related Questions