Home > php教程 > php手册 > body text

PHP中defined()和strrchr()函数的实例

WBOY
Release: 2016-06-13 11:37:38
Original
1210 people have browsed it

defined() 函数

定义和用法

defined() 函数检查某常量是否存在。

若常量存在,则返回 true,否则返回 false。

例子:

define("GREETING","Hello world!");
echo defined("GREETING");
?>

输出:

1

strrchr() 函数

定义和用法
strrchr() 函数查找字符串在另一个字符串中最后一次出现的位置,并返回从该位置到字符串结尾的所有字符。

如果成失败,否则返回 false。

语法
strrchr(string,char)
参数 描述
string 必需。规定被搜索的字符串。
char 必需。规定要查找的字符。如果该参数是数字,则搜索匹配数字 ASCII 值的字符。

例子 1
echo strrchr("Hello world!","world");
?>
输出:

world!
例子 2
echo strrchr("Hello world!",111);
?>
输出:

orld!

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 Recommendations
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!