Search code examples
phpfavicon

favicon generator script give some minor error in php code


hi friends i m just create a demo of php favicon image generator when i trying to submit the image it shows the image in fixed size which you select but it also give a error thats is

Strict Standards: Only variables should be passed by reference in 
C:\xampp\htdocs\demo123\index.php on line 40

line 40

$ext = end(explode(".",strtolower(trim($_FILES["image"]["name"]))));

Solution

  • From PHP.net

    The following things can be passed by reference:
    
    - Variables, i.e. foo($a)
    - New statements, i.e. foo(new foobar())
    - [References returned from functions][2]
    

    So Change your code as below

    $data = trim($_FILES["image"]["name"]);
    $data = strtolower($data);
    $data = explode(".",$data);
    $ext = end($data);
    

    OR

    $ext = pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION);