Foros del Web » Programando para Internet » PHP »

Significado de '%s' en una consulta?

Estas en el tema de Significado de '%s' en una consulta? en el foro de PHP en Foros del Web. Hola nuevamente, Me podrían decir qué significa '%s' en una consulta?, ejemplo: ......... "SELECT * FROM users WHERE user='%s' AND password='%s'", ......... Busqué info pero ...
  #1 (permalink)  
Antiguo 27/12/2010, 14:08
Avatar de elsolodigno  
Fecha de Ingreso: agosto-2009
Mensajes: 225
Antigüedad: 14 años, 8 meses
Puntos: 2
Significado de '%s' en una consulta?

Hola nuevamente,

Me podrían decir qué significa '%s' en una consulta?, ejemplo:

.........
"SELECT * FROM users WHERE user='%s' AND password='%s'",
.........

Busqué info pero no encontré nada relacionado al signo % en php salvo que sirve para algún tipo de división...

Muchas gracias
  #2 (permalink)  
Antiguo 27/12/2010, 14:10
Avatar de spider_boy  
Fecha de Ingreso: diciembre-2003
Ubicación: Chile
Mensajes: 1.855
Antigüedad: 20 años, 4 meses
Puntos: 89
Respuesta: Significado de '%s' en una consulta?

Tomado de PHP, de la función sprintf:

Cita:
#

A type specifier that says what type the argument data should be treated as. Possible types:

* % - 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). The precision specifier stands for the number of digits after the decimal point since PHP 5.2.1. In earlier versions, it was taken as number of significant digits (one less).
* E - like %e but uses uppercase letter (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.
* g - shorter of %e and %f.
* G - shorter of %E and %f.
* 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).
__________________
Nunca te olvidaré mi negra hermosa. Te extraño demasiado.
  #3 (permalink)  
Antiguo 27/12/2010, 14:11
 
Fecha de Ingreso: diciembre-2010
Ubicación: Rosario, Santa Fe
Mensajes: 326
Antigüedad: 13 años, 4 meses
Puntos: 13
Respuesta: Significado de '%s' en una consulta?

http://www.php.net/manual/es/function.sprintf.php
Tal vez con eso se aclare tu duda.

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:40.