一般的な PHP 構文1.PHP は文字列の長さを取得します。
<ol class="dp-xml"><li class="alt"><span><span>$</span><span class="attribute"><font color="#ff0000">length</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">strlen</font></span><span>($str); </span></span></li></ol>
PHP 共通構文 2. PHP は文字が NULL かどうかを判断します:
<ol class="dp-xml"> <li class="alt"><span><span>if(!$str){ </span></span></li> <li class=""><span> echo "false" </span></li> <li class="alt"><span> </span></li> <li class=""><span>}else { </span></li> <li class="alt"><span> echo "true" </span></li> <li class=""><span> </span></li> <li class="alt"><span>} </span></li> </ol>
一般的な PHP 構文 3. link_to の使用:
<ol class="dp-xml"><li class="alt"> <span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> echo link_to($question-</SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong></span><span>getUser(), <br>'user/show?</span><span class="attribute"><font color="#ff0000">id</font></span><span>='.$question-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getUserId()) </span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span> </li></ol>
一般的な PHP 構文 4. PHP インターセプト文字列:
<ol class="dp-xml"> <li class="alt"><span><span>1.split </span></span></li> <li class=""> <span>$</span><span class="attribute"><font color="#ff0000">arr</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>(); </span> </li> <li class="alt"> <span>$</span><span class="attribute"><font color="#ff0000">arr</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">split</font></span><span>("/",$str);</span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>CODE</SPAN><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>SPAN</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>class</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>php_000000</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span> </span> </li> <li class=""> <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>SPAN</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class="alt"> <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>CODE</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> </ol>
PHP共通構文 5. PHP置換文字列:
<ol class="dp-xml"> <li class="alt"><span><span>1. str_replace("-" , "/" , $str) </span></span></li> <li class=""><span>"-" = 要替换的字符 </span></li> <li class="alt"><span>"/" = 替换后的字符 </span></li> <li class=""><span> </span></li> <li class="alt"><span>2.按数组方式替换: </span></li> <li class=""> <span>$</span><span class="attribute"><font color="#ff0000">arr</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>("0","1","2","3","4","5","6","7","8","9"); </span> </li> <li class="alt"> <span>$</span><span class="attribute"><font color="#ff0000">repNum2</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">str_replace</font></span><span>($arr,"",$str); </span> </li> </ol>よく使われるPHP構文 6. PHP は配列の長さを取得します。
<ol class="dp-xml"><li class="alt"><span><span>$</span><span class="attribute"><font color="#ff0000">i</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">count</font></span><span>($array_name); </span></span></li></ol>PHP 共通構文 7. PHP は現在時刻を取得します。
<ol class="dp-xml"><li class="alt"><span><span>$</span><span class="attribute"><font color="#ff0000">current_date</font></span><span> = date("Ymd"); </span></span></li></ol>
上記は、今回まとめた一般的なPHP構文です。
http://www.bkjia.com/PHPjc/446352.html
www.bkjia.com
本当
http://www.bkjia.com/PHPjc/446352.html
技術記事
PHP 共通構文 1.PHP は文字列の長さを取得します: $ length = strlen ($str); PHP 共通構文 2.PHP は文字が NULL かどうかを判断します: if(!$str){ echo "false" }else{ echo "true " } PHP 共通構文 3.l...