PHP中substr函数的作用是返回字符串的一部分,其语法为“substr(string,start,length)”,其参数string表示返回其中一部分的字符串,参数start表示在字符串的何处开始,参数length表示截取长度。

使用示例
";
echo substr("Hello world",1)."
";
echo substr("Hello world",3)."
";
echo substr("Hello world",7)."
";
echo substr("Hello world",-1)."
";
echo substr("Hello world",-10)."
";
echo substr("Hello world",-8)."
";
echo substr("Hello world",-4)."
";
?>";
echo substr("Hello world",1,8)."
";
echo substr("Hello world",0,5)."
";
echo substr("Hello world",6,6)."
";
echo substr("Hello world",0,-1)."
";
echo substr("Hello world",-10,-2)."
";
echo substr("Hello world",0,-6)."
";
echo substr("Hello world",-2-3)."
";
?>推荐教程:《PHP》
免费 盛世企业网站管理系统(SnSee)系统完全免费使用,无任何功能模块使用限制,在使用过程中如遇到相关问题可以去官方论坛参与讨论。开源 系统Web代码完全开源,在您使用过程中可以根据自已实际情况加以调整或修改,完全可以满足您的需求。强大且灵活 独创的多语言功能,可以直接在后台自由设定语言版本,其语言版本不限数量,可根据自已需要进行任意设置;系统各模块可在后台自由设置及开启;强大且适用的后台管理支










