How to use printf in PHP
In this article I will explain how the printf() function can be used in PHP.
printf() function in PHP
- The printf() function is used to output a formatted string.
- In printf() function, The arg1, arg2, ++ parameters will be added at percent (%) signs in the main string.
- The printf() function works "step-by-step".
- In printf() function, you must use placeholders, If there are more % signs than arguments
Syntax
printf(format,arg1,arg2,arg++) |
Parameter
Example
The following example show to how the printf() function can be used in PHP.
<html>
<body>
<h3 style="color: darkblue;">printf() function example in PHP</h3>
<?php
$str = "Hello";
$num = 999;
printf("%s C-sharpcorner user. you visit number is %u",$str,$num);
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here