gpt4 book ai didi

perl - Perl中是否有相当于PHP的addslashes?

转载 作者:行者123 更新时间:2023-12-01 04:54:30 25 4
gpt4 key购买 nike

PHP 加斜杠:

string addslashes ( string $str )

Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash () and NUL (the NULL byte).

An example use of addslashes() is when you're entering data into a database. For example, to insert the name O'reilly into a database, you will need to escape it. It's highly recommended to use DBMS specific escape function (e.g. mysqli_real_escape_string() for MySQL or pg_escape_string() for PostgreSQL), but if the DBMS you're using doesn't have an escape function and the DBMS uses \ to escape special chars, you can use this function. This would only be to get the data into the database, the extra \ will not be inserted. Having the PHP directive magic_quotes_sybase set to on will mean ' is instead escaped with another '.



Perl中是否有相当于PHP的addslashes?

最佳答案

Is there equivalent to PHP's addslashes in Perl?



是的。但你不想那样做。

如果您正在执行数据库查询,处理动态参数的唯一正确方法是使用 DBI placeholders .这些将导致您的参数与查询分开发送(或者如果您的数据库不支持参数化查询,则在查询中正确序列化。)

关于perl - Perl中是否有相当于PHP的addslashes?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8888963/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com