• PHP Video Tutorials

PHP - Function Sprintf



Syntax

string sprintf ( string $format [, mixed $args [, mixed $... ]] )

Definition and Usage

It is used to a formatted string

Return Values

It returns the formatted string

Parameters

Sr.No Parameters & Description
1

format

It specifies the string and how to format the variable in it

2

arg1

It specifies the first argument to be inserted in the formatted string

3

arg2

It specifies the second argument to be inserted in the formatted string

Example

Try out the following example

<?php
   $number = 123;
   $txt = sprintf("%f",$number);
   
   echo $txt;
?>

The result should be as follows

123.000000
php_function_reference.htm
Advertisements