PHP---common codes

WBOY
Release: 2016-08-08 09:24:41
Original
869 people have browsed it

1. Delete the first character of the string:

<code><span>$string</span>=<span>''</span>;
<span>foreach</span>(<span>$array</span><span>as</span><span>$key</span> => <span>$value</span>){
    <span>$string</span> .= <span>",$value"</span>;
}
<span>$string</span> = substr(<span>$string</span>,<span>1</span>);</code>
Copy after login

2. Define the page encoding format:

<code><span><</span>meta http<span>-equiv</span><span>=</span>content<span>-type</span> content<span>=</span><span>"text/html; charset=UTF-8"</span><span>></span><span>header</span>(<span>"Content-type:text/html;charset=utf-8"</span>);</code>
Copy after login

3. Set the running time limit and browser closing limit:

<code><span>set</span>_time_limit(<span>0</span>);
ignore_user_abort(<span>true</span>);</code>
Copy after login

4. Intercept the two strings Part

<code><span><span>function</span><span>getStringMiddlePart</span><span>(<span>$str</span>,<span>$str_begain</span>,<span>$str_end</span>)</span>{</span><span>//请确保$str_begain在$str中的唯一性</span><span>$temp</span> = explode(<span>$str_begain</span>,<span>$str</span>);
    <span>if</span>(!<span>isset</span>(<span>$temp</span>[<span>1</span>])) <span>return</span><span>false</span>;
    <span>$temp</span> = explode(<span>$str_end</span>,<span>$temp</span>[<span>1</span>]);
    <span>return</span><span>$temp</span>[<span>0</span>];
}</code>
Copy after login

The above introduces PHP---commonly used codes, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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!