%s -> whats it??
I am learning PHP and mySQL from Wrox's PHP Programming. I am stuck on a code and can't understand what does it means. Its basically a function and what it does is formats the text inside the function. Here is the code:
When we type GenerateHTMLHeader("Omair Haroon");
printf("font size=+4 face=Arial color="red"><B>");
it would display Omair Haroon in red color.
The only thing I can't understand is what does %s in the fourth line stands for.
Waiting for your help guys.
I just bought this book myself but have yet to reach that stage of it yet.
I'm nearly sure the %s stands for string and the second parameter passed to the printf function is the string you want it to print out. This is similiar to how C++ prints out strings and ints. I hope that helps.
Yes, Anthony is correct. The printf function in PHP is pretty much identical to that of C and C++.
%s, %d, %f are a few examples of what's called 'format specifications' for an array of characters (strings), integer, and a floating point number respectively.
So can I write $message instead of %s ?
Yes, that's correct.
would be a perfectly valid statement. It would perform the same thing as