Changes

Jump to: navigation, search

Working with Strings and Text in PHP

448 bytes added, 13:39, 4 June 2007
PHP fprintf formatting specifiers
<td>%X<td>Hexadecimal number in uppercase letters</td>
</table>
 
before we look at the fomratting options for we first need to see some of the above rules in action. Let's begin by embedding a string variable into a PHP fprintf function call:
 
<pre>
<?php
 
$myString = "Green";
 
$formatted = fprintf ("My favorite color is %s.", $myString);
 
echo $formatted;
 
?>
 
</pre>
 
In the above example the %s will be replaced by the value of $myString to create a string wich reads:
 
<tt>My favorite color is Green.</tt>

Navigation menu