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

PHP or die

PHP or die

Webナイト宮崎 Vol.12 ~てげPHP学びたい~ - connpass https://tegehoge.connpass.com/event/199828/

797d5998ec494edb7ade9ffe8783d105?s=128

Kosuke Ogawa

January 22, 2021
Tweet

Transcript

  1. PHP OR DIE WebφΠτٶ࡚ Vol.12

  2. ࣗݾ঺հ ➤0HBXB,PTVLFʢ!LPPHBXBʣ ➤Ξϧגࣜձࣾ ➤ٶ࡚͔Β౦ژʹϑϧϦϞʔτ ➤J04 4XJGU "OESPJE ,PUMJO  5ZQF4DSJQU

    $44 7VFKT  /VYUKTͳͲ ➤ݸਓ։ൃͰ1)1ʢ஌ࣝ͸7FSY Ͱࢭ·ͬͯΔʣ
  3. Α͘ݟΔʁίʔυ

  4. ಉ͡ϊϦͰ͜͏͔ͨͬͨ͠ PHP Parse error: syntax error, unexpected 'return'

  5. https://stackoverflow.com/questions/14393173/in-php-why-does-or-die-work-but-or-return-doesnt

  6. ͭ·Γɺreturn ͸ʮࣜʯͰ͸ͳ͍

  7. “ࣜ͸ɺPHP ʹ͓͚Δ࠷΋ॏཁͳϏϧσΟϯάϒ ϩοΫͰ͢ɻPHPʹ͓͍ͯ͸ɺ΄ͱΜͲશͯͷ΋ ͷ͸ࣜͰهड़͞Ε·͢ɻ ࠷΋؆୯Ͱ࠷΋ਖ਼֬ͳ ࣜͷఆٛ͸ɺ"஋͕͋Δ΋ͷશͯ"Ͱ͢ɻ ࣜͱ͸ - PHPϚχϡΞϧ

  8. ࣜͷྫ ➤$a = 5 ➤5 ͸ 5 ͱ͍͏஋Λ༗͢Δʮࣜʯ ➤$b =

    $a ➤$a ͸ 5 ͱ͍͏஋Λ࣋ͭʮࣜʯ ➤$c = foo(); ➤foo() ͸ԿΒ͔ͷ஋Λฦ͢ʮࣜʯ
  9. ࠷ॳͷྫΛࢥ͍ग़ͯ͠ΈΔ ➤ $fp = false or die(“hoge”); ΤϥʔʹͳΒͳ͍ ➤ $fp

    = false or return 0; PHP Parse error: syntax error, unexpected ‘return' $fp = ࣜ1 or ࣜ2
  10. ݁࿦ɿΑͬͯɺ࣍ͷίʔυ͸ΤϥʔʹͳΔ PHP Parse error: syntax error, unexpected 'return'

  11. RETURN ➤ ੍ޚߏ଄ͷͻͱͭ

  12. ͋Γ͕ͱ͏ ͍͟͝·ͨ͠