1.实例过程
  在页面添加表单和显示区域结构,并使用css样式进行布局和定位。
  实现返回不同的样式结果,使用了switch多分支结构,html样式标签和字符串连接运算符"."
  这样在用户提交信息的同时,字符串内容也会被html字体样式标签包含在内,可实现不同的字体样式效果。
  2.实例代码
PHP
<!doctype html>
<html lang="en">
<head>
</head>
<div class="fot">提交样式修改字体信息</div>
<div>
    <form action="" method="post">
        <div>
            <input type="text" value="" name="txt">
            <br>
            <h3>请选择样式类型:</h3>
        </div>
        <div>
            加粗 <input type="radio" name="css" value="1" checked>  
            倾斜 <input type="radio" name="css" value="2" >  
            下划线 <input type="radio" name="css" value="3" >  
        </div>
        <input type="submit" value="提交" name="sel">
    </form>
</div>
<div>
    <?php
        if(isset($_POST['sel'])){
            $type =$_POST['css'];
            switch ($type){
                case "1":
                    echo "<b>{$_POST['txt']}</b>";
                    break;
                case "2":
                    echo "<i>{$_POST['txt']}</i>";
                    break;
                case "3":
                    echo "<u>{$_POST['txt']}</u>";
                    break;
                default:
                    exit("参数有错!");
            }
        }
    ?>
</div>
<body>
</body>
</html>
