| Formatting Strings |
| Article Index |
|---|
| Formatting Strings |
| Page 2 |
| Page 3 |
| Page 4 |
If strings are nothing more than a collection of characters to a computer, to a human being they often represent concepts and data that are best presented following certain conventions. Even when dealing with computers, however, it's sometimes necessary to ensure that the contents of a string follow certain rules. For example, strings that must be passed to a Web browser must be formatted according to the HTML standards for them to be properly visualized.
As a result, PHP provides a wide range of functions that can be used to format the contents of a string for a number of occasions. Perhaps the most generic example of this functionality is printf(), whose syntax is as follows:
void printf ($format_specification[, $parameters...]);
The $format_specification parameter is a string that contains both normal text, which is output as is, and replacement directives, which are replaced using the values provided in the $parameters section of the function call.
A replacement directive has the following form:
| Users' Comments (0) |
|
No comment posted









