Yahoo奇摩知識+ 將於 2021 年 5 月 4 日 (美國東部時間) 終止服務。自 2021 年 4 月 20 日 (美國東部時間) 起,Yahoo奇摩知識+ 網站將會轉為唯讀模式。其他 Yahoo奇摩產品與服務或您的 Yahoo奇摩帳號都不會受影響。如需關於 Yahoo奇摩知識+ 停止服務以及下載您個人資料的資訊,請參閱說明網頁。
使用MySQL建立table。%s是什麼意思?
最近學PHP和MySQL,看到書中的範例中有%s的出現,請問%s是要幹麻用的?
例如:
ㄧ、
CREATE TABLE %s(
namechar( 25 ) ,
idchar( 25 ) ,
age int( 3 ) ,
descriptionchar( 25 ) ,
emailchar( 25 ) ,
telephonechar( 25 )
)
二、
$query_Recordset1 = sprintf("SELECT * FROM `user` WHERE m_user = %s", $colname_Recordset1);
這些例子都有%s的出現,請問這是要做什麼用的呢?15點,謝謝喔
1 個解答
- 說走就走Lv 51 0 年前最佳解答
% - a literal percent character. No argument is required. b - the argument is treated as an integer, and presented as a binary number. c - the argument is treated as an integer, and presented as the character with that ASCII value. d - the argument is treated as an integer, and presented as a (signed) decimal number. e - the argument is treated as scientific notation (e.g. 1.2e+2). u - the argument is treated as an integer, and presented as an unsigned decimal number. f - the argument is treated as a float, and presented as a floating-point number (locale aware). F - the argument is treated as a float, and presented as a floating-point number (non-locale aware). Available since PHP 4.3.10 and PHP 5.0.3. o - the argument is treated as an integer, and presented as an octal number. s - the argument is treated as and presented as a string. x - the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters). X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).
是sprintf的函式在使用
以你的例子來說
使設$colname_Recordset1 = 5
$query_Recordset1的結果為
SELECT * FROM `user` WHERE m_user = 5";
再舉例來說明
echo sprintf("%s %s %s",1,2,3);
結果會為
1 2 3