MemoryRefresh!

Printf



Questions 1 Answers 0%

Pages   0 from 51
Questions   0 from 84

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
Questions

Related pages

Basics !
Comparing !
Searching !
Parse !
Replacing !
Formatting !
Printf !
Regexp !
Datetime !


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




2) Which is correct?





3) Which is correct when parsing a stream?




Last Review: n/a   Passed: n/a   Reviews: n/a   Next Review: n/a  


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



More from Php

Basics
Variables
Operators
Function
Array
String
Streams
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com