skip to Main Content

I have update PHPV 7 to PHP 8..1.2 Now whole my application lots of diffrent errors like this.
My main problem is how to solve this issue in the tcpdf library? i have updated the tcpf library the version is "version": "6.3.2", please help me fint the solution.

"Deprecated: Optional parameter $isunicode declared before required parameter $currentfont is implicitly treated as a required parameter in C:wamp64wwwprospectertcpdfincludetcpdf_fonts.php on line 2024

Deprecated: Optional parameter $tidy_options declared before required parameter $tagvspaces is implicitly treated as a required parameter in C:wamp64wwwprospectertcpdfincludetcpdf_static.php on line 1139

Deprecated: Optional parameter $prenom declared before required parameter $TheDate is implicitly treated as a required parameter in C:wamp64wwwprospecterclassModules.php on line 929
Deprecated: number_format(): Passing null to parameter #1 ($num) of type float is deprecated

I works neraly 6 months in php so i need help to solve thease issuse in my app.

2

Answers


  1. Sadly, these notices can’t be fixed for the TCPDF library as that version isn’t getting updated anymore.

    The last 2 notices occur within your own code and can be fixed.

    First notice

    "Deprecated: Optional parameter $prenom declared before required parameter $TheDate is implicitly treated as a required parameter in C:wamp64wwwprospecterclassModules.php on line 929"

    Your code looks something like this:

    function foo($prenom = null, $TheDate) {
        // Your code
    }
    

    Because $prenom has a default value (making it optional) and $TheDate doesn’t (making it required), you are receiving that notice telling you that the order of those parameters doesn’t make sense as you can’t give the second parameter without the first.

    Change it to:

    function foo($prenom, $TheDate) {
        // Your code
    }
    // Alternatively, but you will have to change the order of passed variables in function calls
    function foo($TheDate, $prenom = null) {
        // Your code
    }
    

    Second

    "Deprecated: number_format(): Passing null to parameter #1 ($num) of type float is deprecated"

    This happens because you’re passing a variable that contains null instead of a float like 10.05 which is not going to be allowed anymore in the future.

    If your code works fine regardless of this the easiest fix would be to cast the value to a float.

    $formatted = number_format((float)$number, 2);
    

    Though the best fix would be to make sure $number can’t be null.

    Other notices

    The other notices can be disabled by using the error_reporting() function, but I’d recommend to just disable error reporting for the production environment unless the notices themselves are causing issues in your application.

    I hope this is clear enough and helps you out!

    Login or Signup to reply.
  2. There is an update for TCPDF 2024 here: https://github.com/tecnickcom/TCPDF/tree/6.7.6

    you can simply replace your old one with this new one here.
    This eliminated all errors for PHP8.3

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search