如何使用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'爲一個字符串? –