9 PHP string functions

WBOY
Release: 2016-08-08 09:19:59
Original
893 people have browsed it

PHP strlen() function

strlen() function returns the length of a string, in characters.

<code><span><span><?php</span><span>echo</span> strlen(<span>"Hello world!"</span>);
<span>?></span></span>
输出:12</code>
Copy after login

PHP strpos() function

strpos() function is used to retrieve specified characters or text within a string.

If a match is found, the first matching character position is returned. If no match is found, FALSE will be returned.

<code><span><span><?php</span><span>echo</span> strpos(<span>"Hello world!"</span>,<span>"world"</span>);
<span>?></span></span></code>
Copy after login

The output of the above code is: 6.

Tips: The position of the string "world" in the above example is 6. The reason for 6 (rather than 7) is that the first character in the string is at position 0 instead of 1.

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above has introduced 9 PHP string functions, including relevant 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