adobii520 發問時間： 電腦與網際網路程式設計 · 1 0 年前

# 使用MySQL建立table。%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);

### 1 個解答

• 1 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

• 登入以對解答發表意見