printf() suggestion
| From: | Monte Ohrt | Date: | Wed, 19 Jul 2000 13:45:08 +0000 |
| Subject: | printf() suggestion | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-25095@lists.php.net to get a copy of this message | ||
I had some positive feedback on this in php-general, so
I thought I'd post it here too.
Monte
----------------------------------------------------------------
Hi,
I'm just looking for a general consensus on an idea:
How about extending the functionality of printf() and sprintf()
with a way to format html-encoded and url-encoded strings?
For an example, this:
printf("%h,%u",$string1,$string2);
would be a shorthand way of doing this:
printf("%s,%s",htmlspecialchars($string1),urlencode($string2));
pros:
*) easier to remember and shorter to type than htmlspecialchars()
*) maybe faster, especially if printf() is already being used
*) doesn't break any backward compatibility
*) consolidates some functionality of php to one function call,
constructive toward tighter php code and leaner php language.
cons:
*) duplicates existing functionality
What do you think?