SELECT COUNT(*) AS test FROM %s WHERE id = %d AND tmp_mail <> ''
%s
和%d
是什么?
答案 0 :(得分:21)
这些是使用的格式符号,例如按sprintf()
。例如:
<?php
$sql_template = "SELECT COUNT(*) AS test FROM %s WHERE id = %d AND tmp_mail <> ''";
$sql_real = sprintf($sql_template, 'sometable', 12345);
echo $sql_real;
?>
输出:
SELECT COUNT(*) AS test FROM sometable WHERE id = 12345 AND tmp_mail <> ''
答案 1 :(得分:7)
string 和十进制整数可能是format symbols。