006——php字符串中的处理函数(五)

<?php
/**
 *   一、addslashes()  在预定义字符串前添加反斜杠
 *
 * stripslashes() 把转义字符串前的反斜杠删除
 *
        get_magic_quotes_gpc()  获得PHP INT中是否开启自动转义
 *
 *
 */
//echo phpinfo();
echo get_magic_quotes_gpc();
if(!get_magic_quotes_gpc()){
    $cname=addslashes($_GET['cname']);
    $uname=addslashes($_GET['uname']);
}else{
    $cname=$_GET['cname'];
    $uname=$_GET['uname'];
}
echo $cname;
echo get_magic_quotes_gpc();
?>

<form action="" method="get">
    课程名:<input type="text" name="cname"><br/>
    学员名:<input type="text" name="uname"><br/>
    <button>提交</button>
</form>

  

原文地址:https://www.cnblogs.com/yiweiyihang/p/7791458.html