|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Explaining %s & %d characters
I have been learning about using the PHP API with MySQL. The author shows queries in the book that use %d & %s characters as in the example below.
..while ($row = mysql_fetch_array ($result)) { # print each name twice, once using numeric indices, # once using associative (name) indices printf ("%s %s<BR>\n", $row[0],$row[1]); printf ("%s %s<BR>\n", $row["last_name"], $row["first_name"]); } mysql_free_result ($result); ?> I would imagine that this some how echo the result variable, but what exactly do they mean & do & can someone tell me a bit more about them & their use. Cheers. JD (London) |
|
#2
|
||||
|
||||
|
This is cortesy of printf and co which drags all the way from c. Baiscly, printf() needs to know what exactly you will output and which var type is it going to be, so % signs shows that in this place go get var from the list and stick it here as int/float/string. The full list of % signs can be found on sprintf manpage.
__________________
And you know I mean that. |
|
#3
|
|||
|
|||
|
Thank you Sir Capone.
That is exactly what I wanted to know. Cheers again, JD |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > Explaining %s & %d characters |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|