MemoryRefresh!

String / Printf   Printf



Questions 1 Answers 0%

Pages   0 from 91
Questions   0 from 142

Reset


printf()
<?php printf ("The string is %s %s", "abc", "def"); // The string is abc def sprint()
<?php echo $a = sprintf("The number is %d", "123"); // The number is 123 vsprintf()
<?php echo vsprintf("The string is %s %s", array("abc", "def")); // The string is abc def // Operates as sprintf() but accepts an array of arguments, fprintf()
<?php // write a formatted string to a stream if ($fd = fopen('date.txt', 'w')) { fprintf($fd, "%s-%s-%s", $y, $m, $d); } sscanf()
<?php // instead of formatting output, it allows you to parse formatted input list($serial) = sscanf("SN/331122", "SN/%d"); echo $serial; // 331122 list($month, $day, $year) = sscanf("January 01 2012", "%s %d %d"); echo "$month - $day - $year"; // January - 1 - 2012

Related Pages

Basics
Comparing
Searching
Parse
Replacing
Formatting
Printf
Regexp
Datetime


0% 100%
 
 
0 pages 91 pages
1) Which is correct?




2) Which is correct?





3) Which is correct when parsing a stream?







printf()
<?php printf ("The string is %s %s", "abc", "def"); // The string is abc def sprint()
<?php echo $a = sprintf("The number is %d", "123"); // The number is 123 vsprintf()
<?php echo vsprintf("The string is %s %s", array("abc", "def")); // The string is abc def // Operates as sprintf() but accepts an array of arguments, fprintf()
<?php // write a formatted string to a stream if ($fd = fopen('date.txt', 'w')) { fprintf($fd, "%s-%s-%s", $y, $m, $d); } sscanf()
<?php // instead of formatting output, it allows you to parse formatted input list($serial) = sscanf("SN/331122", "SN/%d"); echo $serial; // 331122 list($month, $day, $year) = sscanf("January 01 2012", "%s %d %d"); echo "$month - $day - $year"; // January - 1 - 2012

References









Programming

Php
   
Regex
   
MySQL
   
Css
   
jQuery
   
Git
   


References