如何使用printf来处理参数,而不管它们的类型如何? (类似PDO中预备声明中的绑定参数)。使用带参数的printf
例如为:
printf("Hello $s, you have $s new notifications.", $username, $newNotifications);
我想类似的东西,并没有工作。
如何使用printf来处理参数,而不管它们的类型如何? (类似PDO中预备声明中的绑定参数)。使用带参数的printf
例如为:
printf("Hello $s, you have $s new notifications.", $username, $newNotifications);
我想类似的东西,并没有工作。
printf
需要知道如何格式化参数。你可以只echo
他们,而不是使用.
连接符:
echo "Hello " . $username . ", you have " . $newNotifications . " new notifications.";
echo "Hello $username, you have $newNotifications new notifications.";
注意良好语法高亮将emphase变量字符串为更好的可读性,使简单的这种方式是最好的。
是不是'%s'为一个字符串? –