Menu

#1147 Getting Error on php 7.4 with TCPDF

v1.0_(example)
open
None
1
2022-10-10
2020-02-15
Amit Yadav
No

I have updated php5 to php7.4 now Facing probelm with TCPDF as it was working properly with php5. Now I am facing two problems as given below

  1. Message: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
    Filename: Tcpdf/Tcpdf.php
    Line Number: 17774
  2. Message: chr() expects parameter 1 to be int, string given
    Filename: include/tcpdf_fonts.php
    Line Number: 1671

Kindly suggest me best solution as I'm not able to find solution of these bugs.

Thanks In Advance.

Discussion

  • Zero

    Zero - 2020-04-17

    I've got the solution for this problem don't know is this the best approach or not but it work.

    public static function unichr($c, $unicode=true) {
            if(is_numeric($c))
            {
                if (!$unicode) {
                    return chr($c);
                } elseif ($c <= 0x7F) {
                    // one byte
                    return chr($c);
                } elseif ($c <= 0x7FF) {
                    // two bytes
                    return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
                } elseif ($c <= 0xFFFF) {
                    // three bytes
                    return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
                } elseif ($c <= 0x10FFFF) {
                    // four bytes
                    return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
                } else {
                    return '';
                }
            }
        }
    

    In the file include/tcpdf_fonts.php, I validate $c to make sure only numeric is allow.

     
  • Jose Manuel

    Jose Manuel - 2022-10-10

    mi me funciono la solución

     

Log in to post a comment.

MongoDB Logo MongoDB