您好我正在使用str_replace,但在我使用额外的复杂性“因此它无法正常工作。我怎么能在str_replace内部使用额外的
$errorAlerts = str_replace("Password found in list of "most common passwords", please choose a more secure password.", "{$record['c_pw']}", $errorsAndAlerts);
感谢您的输入
答案 0 :(得分:3)
逃避
$errorAlerts = str_replace("Password found in list of \"most common passwords\", please choose a more secure password.", $record['c_pw'], $errorsAndAlerts);
或使用单引号
$errorAlerts = str_replace('Password found in list of "most common passwords", please choose a more secure password.', $record['c_pw'], $errorsAndAlerts);
答案 1 :(得分:1)
我们使用双引号文字单引号
$errorAlerts = str_replace('Password found in list of "most common passwords", please choose a more secure password.',
$record['c_pw'],
$errorsAndAlerts);
答案 2 :(得分:1)
您可以在这里使用两种方法
使用\
来转义双引号
$errorAlerts = str_replace("Password found in list of \"most common passwords\", please choose a more secure password.", {$record['c_pw']}, $errorsAndAlerts);
或者您可以使用单引号。
$errorAlerts = str_replace('Password found in list of "most common passwords", please choose a more secure password.', {$record['c_pw']}, $errorsAndAlerts);
要指定文字双引号,请使用反斜杠()对其进行转义。
这是php页面如何使用单引号和双引号的一个很好的参考。查看link