函数:AddSlashes() 
--------------------------------------------------------------------------------
 
字符串处理函数库
AddSlashes
字符串加入斜线。语法: string addslashes(string str);返回值: 字符串函数种类: 资料处理
 
 
内容说明 
本函数使需要让数据库处理的字符串,引号的部份加上斜线,以供数据库查询 (query) 能顺利运作。这些会被改的字符包括单引号 (')、双引号 (")、反斜线 backslash (\) 以及空字符 NUL (the null byte)。

解决方案 »

  1.   

    To:goodnameAddSlashes不会为*[]^之类的加上\号,所以不行!
      

  2.   

    ereg("$<\?//$u", $temp)
          ^--不对吧?匹配空行?
    <?
    $u='*';
    $temp = "<?//ssss";
    if(ereg("<\?//$u", $temp))
    echo "ok";
    ?>
      

  3.   

    http://www.phpe.net/articles/21.shtmlhttp://www.phpe.net/articles/151.shtml
    http://www.phpe.net/articles/22.shtml
      

  4.   

    你想实现什么功能?特殊字符只能自己加,类似这样
    $patterns=array('(\*)','(\.)','(\[)','(\])');
    $replace=array('\\\1','\\\1','\\\1','\\\1');
    $u = preg_replace ($patterns, $replace, $u);
      

  5.   

    给你个js,看看能用吧?
    <script language=Javascript>
    <!--
    function ckform() {
    with (document.addform){
    if(name.value=="") {
    alert("您必须输入您的名字!\nPlease input your names!");
    name.focus();
    return false;
    }

    if(email.value=="") {
    alert("您必须输入您的E-mail地址!\nPlease input your mail!");
    email.focus();
    return false;
    }
    var pattern=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
    if(!pattern.test(email.value)){
    alert("请输入正确的邮箱地址!\nE-mail not accept!");
    email.focus();
    return false;
    }

    var pattern=/([!\@\#\$%^&*()+|\\{}:;?<>`])+/;
    if((pattern.test(name.value))) {
    alert("您的姓名里不能包含非法字符!\nName not accept!");
    name.focus();
    return false;
    }
    var pattern=/^(http:\/\/)[A-Za-z0-9\-]+/;
    if( (!pattern.test(url.value)) && (url.value!="http://") ) {
    alert("请正确输入您的主页!\nHomepage not accept!");
    url.focus();
    return false;
    }
    var pattern=/([!\@\#\$%^&*+|\\{}?<>`])+/;
    if( (pattern.test(subject.value)) || (subject.value=="") ) {
    alert('留言主题不能为空且不能有非法字符!\n Subject not accept!');
    subject.focus();
    return false;
    }
    var pattern=/([!\@\#\$%^&*+|\\{}?<>`])+/;
    if( (pattern.test(message.value)) || (message.value=="") ) {
    alert('您的留言不能为空且不能有非法字符!\n Message not accept!');
    message.focus();
    return false;
    }
    }
    return true;
    }
    //-->
    </script>
      

  6.   

    试试 preg_quote
    http://www.php.net/manual/zh/function.preg-quote.php
      

  7.   

    这个意思呀?
    echo preg_quote("[]?+.*$^(){}"); // out \[\]\?\+\.\*\$\^\(\)\{\}
      

  8.   

    flyk提到的这个函数应该很好用,符合楼主的要求..preg_quote
    (PHP 3>= 3.0.9, PHP 4 )preg_quote -- Quote regular expression characters
    Description
    string preg_quote ( string str [, string delimiter])
    preg_quote() takes str and puts a backslash in front of every character that is part of the regular expression syntax. This is useful if you have a run-time string that you need to match in some text and the string may contain special regex characters. If the optional delimiter is specified, it will also be escaped. This is useful for escaping the delimiter that is required by the PCRE functions. The / is the most commonly used delimiter.The special regular expression characters are: . \\ + * ? [ ^ ] $ ( ) { } = ! < > | :
     
    例子 1. $keywords = "$40 for a g3/400";
    $keywords = preg_quote ($keywords, "/");
    echo $keywords; // returns \$40 for a g3\/400
     
     
    例子 2. Italicizing a word within some text// In this example, preg_quote($word) is used to keep the
    // asterisks from having special meaning to the regular
    // expression.$textbody = "This book is *very* difficult to find.";
    $word = "*very*";
    $textbody = preg_replace ("/".preg_quote($word)."/",
                              "<i>".$word."</i>",
                              $textbody);
     
     
    User Contributed Notes
    preg_quote   
    There are no user contributed notes for this page. 
      

  9.   

    看一下php的帮助文件有介绍
    就是这样用。
    \*\[\]