<?php $str='programming'; //定义一个字符串 $res=substr($str,-4); //处理字符串 echo "返回{$str}字符串的最后4个字符{$res}"; $res=substr($str,0,-4); //处理字符串 echo "<br />返回{$str}字符串除去后4个字符{$res}"; ?>