PHP经典:提取子字符串

简介: PHP经典:提取子字符串

substr:整个字符串 从哪里开始(第一个是下标0) 最后是哪里(比如写8那8-1=7就对了)

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
</head>
<body>
    <form method="get">
        <input type="text" name="username" id="">
        <input type="submit" value="提交">
    </form>
    
</body>
</html>
<?php
        error_reporting(0);
        echo $username=substr($_GET['username'],0,8);
?>
相关文章
php案例:判断这个是繁体字还是简体字(满足绝大部分字符)用php函数
php案例:判断这个是繁体字还是简体字(满足绝大部分字符)用php函数
php案例:判断这个是繁体字还是简体字(满足绝大部分字符)用php函数
|
11月前
|
PHP
php公用函数:获取字符串中英文混合长度
php公用函数:获取字符串中英文混合长度
37 0