Online
 
Thursday, 20 November 2008
 
 

Formatting Strings | Print |  E-Mail
 

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:


This entry was posted on . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a comment. Tags: Simple PHP, Pear, Easy PHP, PHP Tutorial, PHP MySQL, XSLT, Sap Tutorial, CSS Tutorial, XSL FO Java, SQL Tutorial.
Users' Comments (0)

Comment an article
  Name
  E-mail
   Title
Available characters: 4000
 Notify me of follow-up comments
This image contains a scrambled text, it is using a combination of colors, font size, background, angle in order to disallow computer to automate reading. You will have to reproduce it to post on my homepage
Enter what you see:

No comment posted

Jumbo Coklat
 
Top! Top!