0
点赞
收藏
分享

微信扫一扫

实训项目:PHP正则表达式的应用

悲催博士僧 2022-04-04 阅读 15
<!DOCTYPE html><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
    /* 背景可以不要 */
    /*body
    {
        background: url(./fb163613ca66653a9778fffc11e524e.jpg);
    }*/

	
    .box1
    {
        position: relative;
        width: 31.25rem;
        height:25rem;
        border: 0.625rem double #000;
        margin: 0 auto;
        top: 6.25rem;
        box-shadow: 0.625rem 0.625rem 1.25rem 0.3125rem rgb(49, 49, 49);
    }
	
    h1,p,.box_button
    {
        text-align: center;

    }
	
    .box_button
    {
        /* width: 200px;
        border: 1px solid; */
        margin: 0 auto;
    }

    textarea
    {
        resize:none;
    }
	
	.box2
	{
		position: absolute; 	
		top: 31.25rem;
		left: -5.75rem;
		width: 42.5rem;
		height: 22.75rem;
		margin: 0 auto;
		border: 0.625rem double #000;
	}

	.box2 b
	{
		margin-left: 2.25rem;
	}
	
	.box_bottom
	{
		position: absolute;
		margin: 0 auto;
		/* top: -10.25rem; */
	}
</style>
</head>
<body>
	<div class="box_bottom" style="color:#363636;font-weight: bolder;font-family: Courier New">© <span  style="letter-spacing: 1.5px;font-size: 1.6rem;">2022 GHW・WebSite</span></div>		
		<div class="box1">
		      <h1>留言板</h1>
		      <form action="" name="f1" id="f1" method="post">
		          <p>请输你的留言:</p>
		          <p><textarea name="t1" id="t1" cols="60" rows="10"></textarea></p>
		          <div class="box_button">
		              <input type="submit" name="send" id="send" style="margin-right: 50px;">
		              <input type="reset" name="send" id="send">
		          </div>
		          
		      </form>
			  <div class="box2">
				<h1>留言记录...</h1>
			  	<?php
			  	$msg=@$_REQUEST['t1'];  
			  	// $reg='/(\d+)/';         //搞定身高、学号
			  	// $reg='/\d+(\.\d)?/';    //搞定小数点
			  	// $reg='/\d+(\.\d+)?/';    //搞定小数点
			  	// $reg='/[\.*]/';         //搞定英文句号.
			  	// $reg='/(零|一|二|两|三|四|五|六|七|八|九|十)(百|十|零)?(一|二|两|三|四|五|六|七|八|九)?(百|十|零)?(一|二|两|三|四|五|六|七|八|九)?/';       //搞定中文数字 呵呵...
			  	// $reg='/((0|[1-9]\d*)(\.\d+)?)|(一|二|两|三|四|五|六|七|八|九)?(万|千|百|十|零)?/';
			  	
			  	//然后合体!!!
			  	//正则表达式真不想学(弱爆〒▽〒
			  	$reg = '/((0|[1-9]\d*)(\.\d+)?)|(\.\d*)|[\.*]|(零|一|二|两|三|四|五|六|七|八|九|十)(百|十|零)?(一|二|两|三|四|五|六|七|八|九)?(百|十|零)?(一|二|两|三|四|五|六|七|八|九)?/';
			  	if(isset($_REQUEST['send']))
			  	{
			  		if($msg==''){
			  			echo '<b>'.'请输入留言'.'</b>';
			  		}
			  		$jm=preg_replace($reg,"***",$msg);
			  		echo '<b>'.$jm.'</b>';
			  	}
			  	?>
			  	
			  </div>
			 
		</div>
</body>
</html>


输入留言 

点击提交

 

举报

相关推荐

0 条评论