8-20.php
来自「php 和 ajax 开发的一些资料」· PHP 代码 · 共 26 行
PHP
26 行
<?php
echo "<html>"; //输出标准HTML内容
echo "<head>";
echo "<title>";
echo "截取字符串操作的使用";
echo "</title>";
echo "</head>";
echo "<body>";
$string="welcom to beijing!"; //定义字符串
echo "\$string原始内容为:".$string; //输出字符串内容
echo "<p>";
$result1=substr($string,7); //执行截取操作
echo "从第7个字符开始截取内容为:".$result1; //输出截取后内容
echo "<p>";
$result2=substr($string,0,6); //执行截取操作
echo "从第0个字符截取6个字符内容为:".$result2; //输出截取后内容
echo "<p>";
$result3=substr($string,-8); //执行截取操作
echo "从尾端截取8个内容为:".$result3; //输出截取后内容
echo "<p>";
$result4=substr($string,2,-9); //执行截取操作
echo "从第2个位置截取-9内容为:".$result4; //输出截取后内容
echo "</body>";
echo "</html>";
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?