PHP字符操作经典实例
一、字符操作
- 访问子字符串:
strpos()
if (strpos($_POST['email'], '@') === false) {
echo 'The input content is not a legal email';
}
- 提取子字符串:
substr()
$substring = substr($string, $start, $length); // $start 从0开始,$length可以为负数(为空时表示到末尾)
- 替换子字符串:
substr_replace()
8.37KB
文件大小:
评论区