Shorthand for variable format translation

From: Date: Thu, 27 Jul 2000 22:56:10 +0000
Subject: Shorthand for variable format translation
Groups: php.general 
Request: Send a blank email to php-general+get-8688@lists.php.net to get a copy of this message
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

« previous php.general (#8688) next »