首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >PHP经典:替换子字符串

PHP经典:替换子字符串

作者头像
贵哥的编程之路
发布2021-10-09 15:43:58
发布2021-10-09 15:43:58
3K0
举报

substr_replace:整个字符串(从这里结束) 替换成这个变量 从什么开始(默认从下标0开始)

代码语言:javascript
复制
<!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);
		$new_substring="cyg&liwen";
	   echo  $new_string=substr_replace($_GET['username'],$new_substring,6);
?>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021/10/03 ,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档