259
PHP string printf() Function
PHP string printf() function predefined functions. It is used to output a formatted string. We can pass the arg1, arg2, arg++ parameters at percent (%) signs in the main string.
Syntax:
Parameter | Description | Required/Optional |
---|---|---|
format | Specify the string. Following are the possible format values:
| Required |
arg1 | The argument to be inserted at the first %-sign. | Required |
arg2 | The argument to be inserted at the second %-sign. | Optional |
arg++ | The argument to be inserted at the third,fourth, etc. %s sign | optional |
Example 1
Output:
We are Learning PHP 7 form TutorAspire .
Example 2
Output:
12345.000000
Example 3
Output:
With 2 decimals: 23456.00 With no decimals: 23456
Example 4
Output:
[Hello] [ Hello] [Hello ] [000Hello] [***Hello] [Hello PH]
Next TopicPHP String