PHP Snippets: Sprintf

PHPThis post is part of the PHP Snippets series where I will be covering the basics of developing in PHP.

The sprintf function provides the same functionality as the printf function, but silently.

This means you would either need to echo the output or concatenate it with a string and echo that string.

$number = 500;
$string = 'miles';

echo sprintf( 'But I would walk %d %s', $number, $string );

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Leave a Reply

Your email address will not be published. Required fields are marked *