RE: [PHP] Shorthand for variable format translation
| From: | John Coggeshall | Date: | Fri, 28 Jul 2000 11:55:59 +0000 |
| Subject: | RE: [PHP] Shorthand for variable format translation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8692@lists.php.net to get a copy of this message | ||
Personally I like that idea, especially the
$[%]foo = foofunction($foo);
That would be the best way.
John
-----Original Message-----
From: Greg Billock [mailto:billgr@optics.caltech.edu]
Sent: Thursday, July 27, 2000 6:56 PM
To: php-general@lists.php.net
Subject: [PHP] Shorthand for variable format translation
What do folks think of this idea?
The idea being, for some variable $foo, it is frequently desired to
a. put it in the database using addslashes($foo);
b. use it in an form control using htmlspecialchars($foo);
c. include it in a linkable URL using urlencode($foo);
perhaps more.
Wouldn't it be nice to be able to use a shorthand for
these frequent translations of variables by being able to use just:
a. (for database) $/foo
b. (for htmlchars) $>foo
c. (for urlencode) $%foo
etc. The mnemonics hopefully being obvious. :-)
Perhaps even a user-defined shorthand, like
$[non-variable-beginning-char]variable is-mapped-to
SomeFunction($variable)
some other ideas..... $|foo maps a variable into some standard PHP
XML format; $:foo maps to serialize(foo), $_foo maps to a WDDX-encoded
format; $#foo maps to strlen($foo) or count($foo) [this would mimic
perl].
Obviously this wouldn't be intended to replace existing functionality,
just
to provide a shorthand for these very-common web applications tasks and
produce ever-more-inscrutable code. :-)
-Greg
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net