What is the difference between mysql_real_escape_string and addslashes?

后端 未结 5 1340
野性不改
野性不改 2020-12-31 15:32

mysql_real_escape_string and addslashes are both used to escape data before the database query, so what\'s the difference? (This question is not ab

5条回答
  •  醉梦人生
    2020-12-31 15:48

    case 1:

    $str = "input's data";
    
    print mysql_real_escape_string($str);      input\'s data
    
    print addslashes($str);                    input\'s data;
    

    case 2:

    $str = "input\'s data";
    
    print mysql_real_escape_string($str);      input\'s data
    
    print addslashes($str);                    input\\'s data;
    

提交回复
热议问题