Heim >Backend-Entwicklung >PHP-Tutorial >弱类型语言比强类型语言的优势、劣势、分别是什么?能用两种语言如 PHP 和 C# 举例论证吗?
PHP 是最好的语言好吧,我再说一遍等于我也有责任。
<code class="language-php"><span class="cp"><?php </span>
<span class="cm">/*</span>
<span class="cm">strpos(string, find)</span>
<span class="cm">返回字符串在另一字符串中第一次出现的位置,如果没有找到字符串则返回 FALSE。</span>
<span class="cm">*/</span>
<span class="nv">$string</span> <span class="o">=</span> <span class="s1">'zhihu'</span><span class="p">;</span>
<span class="nv">$find</span> <span class="o">=</span> <span class="s1">'h'</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">strpos</span><span class="p">(</span><span class="nv">$string</span><span class="p">,</span> <span class="nv">$find</span><span class="p">)</span> <span class="o">==</span> <span class="k">false</span><span class="p">)</span>
<span class="k">echo</span> <span class="s1">'not found'</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">strpos</span><span class="p">(</span><span class="nv">$string</span><span class="p">,</span> <span class="nv">$find</span><span class="p">))</span>
<span class="k">echo</span> <span class="s1">'not found'</span><span class="p">;</span>
<span class="nv">$find</span> <span class="o">=</span> <span class="s1">'z'</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">strpos</span><span class="p">(</span><span class="nv">$string</span><span class="p">,</span> <span class="nv">$find</span><span class="p">)</span> <span class="o">==</span> <span class="k">false</span><span class="p">)</span>
<span class="k">echo</span> <span class="s1">'not found'</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">strpos</span><span class="p">(</span><span class="nv">$string</span><span class="p">,</span> <span class="nv">$find</span><span class="p">))</span>
<span class="k">echo</span> <span class="s1">'not found'</span><span class="p">;</span>
<span class="cp">?></span><span class="x"></span>
</span></code>