Summary notes on common PHP syntax_PHP tutorial

WBOY
Release: 2016-07-15 13:29:40
Original
731 people have browsed it

PHP common syntax1.PHP gets the string length:

<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>
Copy after login

PHP common syntax 2. PHP determines whether a character is 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>
Copy after login

PHP common syntax 3. Use of 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>
Copy after login

PHP commonly used Syntax 4. PHP intercepts string:

<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>
Copy after login

PHP commonly used Syntax 5. PHP replacement string:

<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>
Copy after login

PHP common syntax 6. PHP gets the array length:

<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>
Copy after login

PHP common syntax 7. PHP gets the current time:

<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>
Copy after login

The above is what we summarize for you this time Common PHP syntax.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446352.htmlTechArticlePHP common syntax 1. PHP gets the string length: $ length = strlen ($str); PHP common syntax 2 .PHP determines whether the character is NULL: if(!$str){ echo "false" }else{ echo "true" } PHP common syntax 3.l...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!