PHP字符操作经典实例

一、字符操作

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