diff options
Diffstat (limited to 'vhosts/blog/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html')
| -rw-r--r-- | vhosts/blog/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/vhosts/blog/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html b/vhosts/blog/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html index f91cef9e..01806f5b 100644 --- a/vhosts/blog/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html +++ b/vhosts/blog/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html @@ -83,7 +83,7 @@ <p> 注意: これはボツ問なので、得られたトークンを PHPerKaigi で入力してもポイントにはならない。 </p> - <div class="codeblock" language="php"> + <div class="codeblock"> <pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span style="color:#D73A49"><?</span><span style="color:#005CC5">php</span><span style="color:#005CC5"> printf</span><span style="color:#24292E">((</span><span style="color:#005CC5">isset</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">?fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">trim</span><span style="color:#24292E">($s,</span><span style="color:#032F62">""</span><span style="color:#24292E">)</span><span style="color:#D73A49">:fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">chr</span><span style="color:#24292E">(</span><span style="color:#005CC5">strlen</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">/</span><span style="color:#005CC5">3</span><span style="color:#24292E">))($s</span><span style="color:#D73A49">=</span><span style="color:#032F62">'<?php printf((isset($s)?fn($s)=>trim($s,""):fn($s)=>chr(strlen($s)/3))($s=%s)."\n","\x27$s\x27");?>'</span><span style="color:#24292E">)</span><span style="color:#D73A49">.</span><span style="color:#032F62">"</span><span style="color:#005CC5">\n</span><span style="color:#032F62">"</span><span style="color:#24292E">,</span><span style="color:#032F62">"</span><span style="color:#005CC5">\x27</span><span style="color:#24292E">$s</span><span style="color:#005CC5">\x27</span><span style="color:#032F62">"</span><span style="color:#24292E">);</span><span style="color:#D73A49">?></span></span> <span class="line"><span style="color:#D73A49"><?</span><span style="color:#005CC5">php</span><span style="color:#005CC5"> printf</span><span style="color:#24292E">((</span><span style="color:#005CC5">isset</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">?fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">trim</span><span style="color:#24292E">($s,</span><span style="color:#032F62">""</span><span style="color:#24292E">)</span><span style="color:#D73A49">:fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">chr</span><span style="color:#24292E">(</span><span style="color:#005CC5">strlen</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">/</span><span style="color:#005CC5">3</span><span style="color:#24292E">))($s</span><span style="color:#D73A49">=</span><span style="color:#032F62">'<?php printf((isset($s)?fn($s)=>trim($s,""):fn($s)=>chr(strlen($s)/3))($s=%s)."\n","\x27$s\x27");?>'</span><span style="color:#24292E">)</span><span style="color:#D73A49">.</span><span style="color:#032F62">"</span><span style="color:#005CC5">\n</span><span style="color:#032F62">"</span><span style="color:#24292E">,</span><span style="color:#032F62">"</span><span style="color:#005CC5">\x27</span><span style="color:#24292E">$s</span><span style="color:#005CC5">\x27</span><span style="color:#032F62">"</span><span style="color:#24292E">);</span><span style="color:#D73A49">?></span></span> <span class="line"><span style="color:#D73A49"><?</span><span style="color:#005CC5">php</span><span style="color:#005CC5"> printf</span><span style="color:#24292E">((</span><span style="color:#005CC5">isset</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">?fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">trim</span><span style="color:#24292E">($s,</span><span style="color:#032F62">""</span><span style="color:#24292E">)</span><span style="color:#D73A49">:fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">chr</span><span style="color:#24292E">(</span><span style="color:#005CC5">strlen</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">/</span><span style="color:#005CC5">3</span><span style="color:#24292E">))($s</span><span style="color:#D73A49">=</span><span style="color:#032F62">'<?php printf((isset($s)?fn($s)=>trim($s,""):fn($s)=>chr(strlen($s)/3))($s=%s)."\n","\x27$s\x27");?>'</span><span style="color:#24292E">)</span><span style="color:#D73A49">.</span><span style="color:#032F62">"</span><span style="color:#005CC5">\n</span><span style="color:#032F62">"</span><span style="color:#24292E">,</span><span style="color:#032F62">"</span><span style="color:#005CC5">\x27</span><span style="color:#24292E">$s</span><span style="color:#005CC5">\x27</span><span style="color:#032F62">"</span><span style="color:#24292E">);</span><span style="color:#D73A49">?></span></span> @@ -104,7 +104,7 @@ <p> 実行してみると、次のような出力が得られる。 </p> - <div class="codeblock" language="php"> + <div class="codeblock"> <pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span style="color:#6A737D">#</span></span> <span class="line"><span style="color:#D73A49"><?</span><span style="color:#005CC5">php</span><span style="color:#005CC5"> printf</span><span style="color:#24292E">((</span><span style="color:#005CC5">isset</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">?fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">trim</span><span style="color:#24292E">($s,</span><span style="color:#032F62">""</span><span style="color:#24292E">)</span><span style="color:#D73A49">:fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">chr</span><span style="color:#24292E">(</span><span style="color:#005CC5">strlen</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">/</span><span style="color:#005CC5">3</span><span style="color:#24292E">))($s</span><span style="color:#D73A49">=</span><span style="color:#032F62">'<?php printf((isset($s)?fn($s)=>trim($s,""):fn($s)=>chr(strlen($s)/3))($s=%s)."\n","\x27$s\x27");?>'</span><span style="color:#24292E">)</span><span style="color:#D73A49">.</span><span style="color:#032F62">"</span><span style="color:#005CC5">\n</span><span style="color:#032F62">"</span><span style="color:#24292E">,</span><span style="color:#032F62">"</span><span style="color:#005CC5">\x27</span><span style="color:#24292E">$s</span><span style="color:#005CC5">\x27</span><span style="color:#032F62">"</span><span style="color:#24292E">);</span><span style="color:#D73A49">?></span></span> <span class="line"><span style="color:#D73A49"><?</span><span style="color:#005CC5">php</span><span style="color:#005CC5"> printf</span><span style="color:#24292E">((</span><span style="color:#005CC5">isset</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">?fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">trim</span><span style="color:#24292E">($s,</span><span style="color:#032F62">""</span><span style="color:#24292E">)</span><span style="color:#D73A49">:fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">chr</span><span style="color:#24292E">(</span><span style="color:#005CC5">strlen</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">/</span><span style="color:#005CC5">3</span><span style="color:#24292E">))($s</span><span style="color:#D73A49">=</span><span style="color:#032F62">'<?php printf((isset($s)?fn($s)=>trim($s,""):fn($s)=>chr(strlen($s)/3))($s=%s)."\n","\x27$s\x27");?>'</span><span style="color:#24292E">)</span><span style="color:#D73A49">.</span><span style="color:#032F62">"</span><span style="color:#005CC5">\n</span><span style="color:#032F62">"</span><span style="color:#24292E">,</span><span style="color:#032F62">"</span><span style="color:#005CC5">\x27</span><span style="color:#24292E">$s</span><span style="color:#005CC5">\x27</span><span style="color:#032F62">"</span><span style="color:#24292E">);</span><span style="color:#D73A49">?></span></span> @@ -119,7 +119,7 @@ <p> 1 行目を除き、先ほどのコードとほぼ同じものが出てきた。もう一度実行してみる。 </p> - <div class="codeblock" language="php"> + <div class="codeblock"> <pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span style="color:#6A737D">#</span></span> <span class="line"><span style="color:#005CC5">W</span></span> <span class="line"><span style="color:#D73A49"><?</span><span style="color:#005CC5">php</span><span style="color:#005CC5"> printf</span><span style="color:#24292E">((</span><span style="color:#005CC5">isset</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">?fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">trim</span><span style="color:#24292E">($s,</span><span style="color:#032F62">""</span><span style="color:#24292E">)</span><span style="color:#D73A49">:fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">chr</span><span style="color:#24292E">(</span><span style="color:#005CC5">strlen</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">/</span><span style="color:#005CC5">3</span><span style="color:#24292E">))($s</span><span style="color:#D73A49">=</span><span style="color:#032F62">'<?php printf((isset($s)?fn($s)=>trim($s,""):fn($s)=>chr(strlen($s)/3))($s=%s)."\n","\x27$s\x27");?>'</span><span style="color:#24292E">)</span><span style="color:#D73A49">.</span><span style="color:#032F62">"</span><span style="color:#005CC5">\n</span><span style="color:#032F62">"</span><span style="color:#24292E">,</span><span style="color:#032F62">"</span><span style="color:#005CC5">\x27</span><span style="color:#24292E">$s</span><span style="color:#005CC5">\x27</span><span style="color:#032F62">"</span><span style="color:#24292E">);</span><span style="color:#D73A49">?></span></span> @@ -134,7 +134,7 @@ <p> 今度は 2 行目が書き換えられた。すべての行が変化するまで繰り返すと次のようになる。 </p> - <div class="codeblock" language="php"> + <div class="codeblock"> <pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span style="color:#6A737D">#</span></span> <span class="line"><span style="color:#005CC5">W</span></span> <span class="line"><span style="color:#005CC5">E</span></span> @@ -158,7 +158,7 @@ <p> Vim で開くと次のようになる (1 行目を抜粋)。 </p> - <div class="codeblock" language="php"> + <div class="codeblock"> <pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span style="color:#D73A49"><?</span><span style="color:#005CC5">php</span><span style="color:#005CC5"> printf</span><span style="color:#24292E">((</span><span style="color:#005CC5">isset</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">?fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">trim</span><span style="color:#24292E">($s,</span><span style="color:#032F62">"<200b>"</span><span style="color:#24292E">)</span><span style="color:#D73A49">:fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">chr</span><span style="color:#24292E">(</span><span style="color:#005CC5">strlen</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">/</span><span style="color:#005CC5">3</span><span style="color:#24292E">))($s</span><span style="color:#D73A49">=</span><span style="color:#032F62">'<200b><?php printf((isset($s)?fn($s)=>trim($s,"<200b>"):fn($s)=>chr(strlen($s)/3))($s=%s)."\n","\x27$s\x27");?>'</span><span style="color:#24292E">)</span><span style="color:#D73A49">.</span><span style="color:#032F62">"</span><span style="color:#005CC5">\n</span><span style="color:#032F62">"</span><span style="color:#24292E">,</span><span style="color:#032F62">"</span><span style="color:#005CC5">\x27</span><span style="color:#24292E">$s</span><span style="color:#005CC5">\x27</span><span style="color:#032F62">"</span><span style="color:#24292E">);</span><span style="color:#D73A49">?></span></span></code></pre> </div> <p> @@ -180,13 +180,13 @@ <p> 続いて、トークンへの変換ロジックを解析する。注目すべきはこの部分だ。以下、ゼロ幅スペースは Vim での表示に合わせて <code><200b></code> と記載する。 </p> - <div class="codeblock" language="php"> + <div class="codeblock"> <pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span style="color:#D73A49">fn</span><span style="color:#24292E">($s)=></span><span style="color:#005CC5">chr</span><span style="color:#24292E">(</span><span style="color:#005CC5">strlen</span><span style="color:#24292E">($s)</span><span style="color:#D73A49">/</span><span style="color:#005CC5">3</span><span style="color:#24292E">)</span></span></code></pre> </div> <p> PHP の <code>strlen()</code> は文字列のバイト数を返す。1 行目の <code>$s</code> は以下の内容となっており、 </p> - <div class="codeblock" language="php"> + <div class="codeblock"> <pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span style="color:#24292E">$s</span><span style="color:#D73A49">=</span><span style="color:#032F62">'<200b><?php printf((isset($s)?fn($s)=>trim($s,"<200b>"):fn($s)=>chr(strlen($s)/3))($s=%s)."\n","\x27$s\x27");?>'</span></span></code></pre> </div> <p> |
