INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
PHP
DETAILS
Question: What is the use of sprintf() function?
Answer: The sprintf() function writes a formatted string to a variable.
The arg1, arg2, ++ parameters will be inserted at percent (%) signs in the main string. This function works "step-by-step". At the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted, etc.
|
Question:
What is the use of sprintf() function?
Answer:
The sprintf() function writes a formatted string to a variable.
The arg1, arg2, ++ parameters will be inserted at percent (%) signs in the main string. This function works "step-by-step". At the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted, etc. Source: CoolInterview.com
Answered by: Amit Joshi | Date: 4/14/2010
| Contact Amit Joshi
sprintf() return a formatted string. Source: CoolInterview.com
Answered by: Arghadip | Date: 4/25/2010
| Contact Arghadip
What is the use of sprintf() function? plz send me answer Source: CoolInterview.com
Answered by: santosh bharti | Date: 4/25/2010
| Contact santosh bharti
The sprintf() function writes a formatted string to a variable.
The arg1, arg2, ++ parameters will be inserted at percent (%) signs in the main string. This function works "step-by-step". At the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted, etc.
example <?php $str = "Hello"; $number = 123; $txt = sprintf("%s world. Day number %u",$str,$number); echo $txt; ?> output Hello world. Day number 123
Source: CoolInterview.com
Answered by: Prakash Kumar | Date: 5/5/2010
| Contact Prakash Kumar
Returns a string produced according to the formatting string format. example:
<?php $location='alipur'; $num=10; $format = 'The %s contains %d tigers'; printf($format,$location,$num); ?> Source: CoolInterview.com
Answered by: nil | Date: 5/5/2010
| Contact nil
printf is a function.it is same as echo and print.but they are constractors. Source: CoolInterview.com
Answered by: hari | Date: 5/13/2010
| Contact hari
The sprintf() function writes a formatted string to a variable.
The arg1, arg2, ++ parameters will be inserted at percent (%) signs in the main string. This function works "step-by-step". At the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted, etc.
Source: CoolInterview.com
Answered by: manoj | Date: 5/14/2010
| Contact manoj
With printf() and sprintf() functions, escape character is not backslash '' but rather '%'.
Ie. to print '%' character you need to escape it with itself: <?php printf('%%%s%%', 'koko'); #output: '%koko%' ?> Source: CoolInterview.com
Answered by: Brij Raj Singh | Date: 5/18/2010
| Contact Brij Raj Singh
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|