Upgrade to Pro — share decks privately, control downloads, hide ads and more …

あの日見たバグを僕達はまだ公式ドキュメントで見れない / The bug we saw that day

あの日見たバグを僕達はまだ公式ドキュメントで見れない / The bug we saw that day

2017/01/31 PHP 勉強会 での LT 資料です

Yoshihide Taniguchi

January 31, 2017
Tweet

More Decks by Yoshihide Taniguchi

Other Decks in Programming

Transcript

  1. ୩ޱఓӳ!SBWFMMM
    ͋ͷ೔ݟͨόάͷৄࡉΛ
    ๻ୡ͸·ͩ
    ެࣜυΩϡϝϯτͰ
    ݟΕͳ͍

    View full-size slide

  2. ࠓ೔࿩͢͜ͱ
    w1)1ͷόʔδϣϯΞοϓதʹ౿Μͩόάʹ͍ͭͯ
    wܦҢ
    wࣄ݅
    wରԠ

    View full-size slide

  3. ୩ޱఓӳ@ravelll
    ( ͨʹ͙ͪc͙ͬ͞Μ
    ͱݺ͹Ε͍ͯ·͢

    View full-size slide

  4. 1)1ͷόʔδϣϯΞοϓΛ΍͍ͬͯͨ
    w͋Δ8FCΞϓϦέʔγϣϯͷϩʔϧ
    $ wc -l $(find . -name \*.php) | tail -1 

    325048 total
    w1)11)1
    wίʔυमਖ਼͕΄΅΄΅׬ྃɺಈ࡞ݕূΛ͍ͯͨ͠

    View full-size slide

  5. ͋Εͬ͜ͷػೳಈ͔ͳ͍ʜ
    wϖʔδʹΞΫηεͨ͠ΒඇಉظʹσʔλΛऔಘɾඳը
    w"KBYͰ(&5ͯ͠KTPOड͚औͬͯඳը
    wKTPOऔಘ࣌ʹ1)1ଆͰΤϥʔ͕ग़͍ͯͨ
    •PHP Warning: mb_convert_variables(): Cannot handle
    recursive references in ʙ

    View full-size slide

  6. mb_convert_variables()

    View full-size slide

  7. NC@DPOWFSU@WBSJBCMFT
    ͱ͸ʁ
    wม਺ͷ஋ͷΤϯίʔσΟϯάΛม׵͢Δؔ਺
    ex) mb_convert_variables(‘UTF-8’, ’EUC-JP’, $var);
    w$varʹ͸4USJOH "SSBZ 0CKFDUΛ౉ͤΔ
    wNC@DPOWFSU@FODPEJOHͱҾ਺ͷॱ͕ҧ͏ʢ͔Θ͍͍ʣ
    mb_convert_variables($to_enc, $from_enc, $var);
    mb_convert_encoding($str, $to_enc[, $from_enc]);

    View full-size slide

  8. Cannot handle recursive references in …

    View full-size slide

  9. Cannot handle recursive references in …

    View full-size slide

  10. SFDVSTJWFͳSFGFSFODFTʁ

    View full-size slide


  11. wͦΜͳ഑ྻ͸౉͍ͯ͠ͳ͍ͧʜʁ
    wͱ͍͏͔ [‘a’, ‘b’] Ͱ͢Βಉ͡ΤϥʔʹͳΔͧʁʁʁ
    ‎Ͳ͔͜ͷόʔδϣϯͰ࢓༷͕มΘͬͨʹҧ͍ͳ͍ʂ

    ެࣜυΩϡϝϯτΛಡ΋͏ʂʂ

    View full-size slide

  12. ಛʹݴٴ͞Εͯͳ͍

    View full-size slide

  13. ΢ʔϜࠔͬͨʜ
    wόʔδϣϯΞοϓલޙͰ1)1ͷιʔεΛಡΈൺ΂ͯΈͨ΋ͷͷ

    $ݴޠྗ͕௿ͯ͘࠶ؼࢀরΛݕ஌͢Δ࢓૊Έ͕૿͑ͯΔ͜ͱҎ֎Α
    ͘෼͔Βͳ͍ʜ
    wNC@DPOWFSU@FODPEJOHؔ਺Λ࢖͏Α͏ʹΞϓϦέʔγϣϯͷ࣮૷
    Λ௚͍͔ͯ͘͠͠ͳ͍ͷ͔ʜ͍΍Ͱ΋݁ߏ࢖ͬͯΔͱ͜Ζ͋Δʜ

    View full-size slide

  14. ؔ਺ͷόάͩͬͨ໛༷
    ‣ୈҾ਺ʢม׵ݩͷΤϯίʔσΟϯάʣʹͭҎ্ͷΤϯίʔσΟϯ
    άΛࢦఆͨ͠ͱ͖ɺม׵ର৅ͷ"SSBZͷ࠶ؼతࢀরͷݕ͕ࠪਖ਼ৗʹ
    Ͱ͖ͳ͍
    ex) mb_convert_variables(‘UTF-8’, ‘EUC-JP,Shift_JIS’, $val);
    mb_convert_variables(‘UTF-8’, ‘auto’, $val);
    (‘auto’ ͸ΤΠϦΞεͰɺmbstring.language=Japanese

    ͷͱ͖ͳΒ ‘ASCII,JIS,UTF-8,EUC-JP,SJIS’)

    View full-size slide

  15. मਖ਼ϓϧϦΫग़ͯͨʢʣ
    ‣·͞ʹɺͳςετ͕௥Ճ͞Ε͍ͯͨʜʂ

    View full-size slide

  16. ରԠ
    wόά͕ੜ·ΕΔ௚લͷόʔδϣϯʢʣΛ࢖͏͜ͱʹͨ͠
    w΋͏1)1ܥ΋"DUJWF4VQQPSUͰͳ͘ͳΓେ͖ͳػೳ௥
    Ճ͕ͳ͍
    wࠓؤுͬͯͱ͔ʹ͢ΔΑΓ͸9ʹ͢΂͘ؤுͬͨ
    ΄͏͕Α͍ͷͰ͸ʜʁ

    View full-size slide

  17. ·ͱΊ
    wόʔδϣϯΞοϓதʹݴޠͷόάͱग़ձͬͨ࿩Λڞ༗͠·ͨ͠
    wNC@DPOWFSU@WBSJBCMFTͰϋϚͬͨ
    wݪҼ͕υΩϡϝϯτʹॻ͔Εͯͳ͔ͬͨ

    ʢݴٴͨ͠Ϣʔβίϝϯτ͸͋ͬͨʣ
    wؔ਺ࣗମʹόά͕͋Δ͜ͱ͕෼͔ͬͨ
    w1)1Λ࢖͏͜ͱͰҰ୴ճආͨ͠

    View full-size slide