p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Re: %d and %s variables


Message #1 by Jefferis Peterson <jefferis@p...> on Mon, 21 Oct 2002 10:40:25 -0400
I am sending this question to the php list because I was told it is php
related and not sql related.

notice that in a lot of query examples using variables
Like this:
> $query_limit_yellow = sprintf("%s LIMIT %d, %d", $query_yellow,
> $startRow_yellow, $maxRows_yellow);

 these seemingly undefined items "%s %d, %d"  are used.


Could someone please explain why or how these things work?

Jeff 


~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year

Message #2 by "Gerry Vandermaesen" <gerry@a...> on Mon, 21 Oct 2002 18:50:51 +0200
You should find an answer to your question on
http://www.php.net/manual/en/function.sprintf.php

The short notation represent the datatypes of the variables used. %s is
a string, %d is an integer.

-----Original Message-----
From: Jefferis Peterson [mailto:jefferis@p...] 
Sent: maandag 21 oktober 2002 16:40
To: beginning php
Subject: [beginning_php] Re: %d and %s variables


I am sending this question to the php list because I was told it is php
related and not sql related.

notice that in a lot of query examples using variables
Like this:
> $query_limit_yellow = sprintf("%s LIMIT %d, %d", $query_yellow, 
> $startRow_yellow, $maxRows_yellow);

 these seemingly undefined items "%s %d, %d"  are used.


Could someone please explain why or how these things work?

Jeff 


~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year



Message #3 by "KayKay-GG \(E-mail\)" <kaykay@g...> on Mon, 21 Oct 2002 23:04:16 +0530
It's similar to C code..
In your example:
$query_limit_yellow = sprintf("%s LIMIT %d, %d",
$query_yellow,$startRow_yellow, $maxRows_yellow);
%s = string ($query_yellow)
%d = int ($startRow_yellow)
%d = int ($maxRows_yellow)

hope that helps :)
-K

>>>>-----Original Message-----
>>>>From: Jefferis Peterson [mailto:jefferis@p...]
>>>>Sent: 21 October 2002 20:10
>>>>To: beginning php
>>>>Subject: [beginning_php] Re: %d and %s variables
>>>>
>>>>
>>>>I am sending this question to the php list because I was
>>>>told it is php
>>>>related and not sql related.
>>>>
>>>>notice that in a lot of query examples using variables
>>>>Like this:
>>>>> $query_limit_yellow = sprintf("%s LIMIT %d, %d", $query_yellow,
>>>>> $startRow_yellow, $maxRows_yellow);
>>>>
>>>> these seemingly undefined items "%s %d, %d"  are used.
>>>>
>>>>
>>>>Could someone please explain why or how these things work?
>>>>
>>>>Jeff



Message #4 by Jefferis Peterson <jefferis@p...> on Mon, 21 Oct 2002 15:53:01 -0400
Thanks all. Just didn't make sense to me and couldn't find it in the back of
the book :-) 


On 10/21/02 1:34 PM, "KayKay-GG (E-mail)" <kaykay@g...> wrote:

> 
> hope that helps :)
> -K

~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year


  Return to Index