[PHP] Re: Using constructs like unset() in expressions like ()()
Richard Lynch wrote: Perhaps something like this: function my_unset($var){ global $$var; $wasset = isset($$var); unset($$var); return $wasset; } my_unset(a); //unset($a); Or, in a more general way: function forcereturn ($php){ return eval($php); } Damned if I understand *why* you want this, mind you. :-) Thank you, Richard. That's what I am looking for. Your first solution may not be usable, because the variable to unset may not be a global variable. The second solution (that using eval()) may have a bug, because the unset() is called in a local-scope of the function forcereturn() (and so the variable unset()ted differs from the variable that we really want to unset()). However, there can be used eval() instead of forcereturn(): ?php (True==False) or (eval('unset($a);')); ? Nevertheless, this solution has defects for general use: A lot of expressions with no return value can't be called with eval() (e.g. eval('break;') is not a good idea). However I don't say I need to use a break command. All I needed was already said. Thank you. --Tomas_Tintera ps. I want it because it seems to be practical to write the whole program in a one expression (usually composed of AND and OR operators). And it's nice. When reading such a code, you can feel as when reading poetry ;). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Using constructs like unset() in expressions like ()()
Thanks for your answers (you probably don't understand me). I am looking for some construct (or statement or function) which allows to do this: ?php (True==False) or (construct_i_am_looking_for(unset($a))); ? Note that the unset() has no return value (and so it can't be used as a part of other expression; it can be only used as a stand-alone statement), so I thing it could be good if there were some construct which makes expression with return value from expression with no return value. It is not possible to use just ?php (True==False) or (unset($a)); ? I have read the whole front section of the PHP manual (and a lot of the rest) but haven't found a construct like that. Is there such a construct in PHP? If there is, what is its name? --Tomas_Tintera -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Using constructs like unset() in expressions like ()()
Thanks for your answers (you probably don't understand me). I am looking for some construct (or statement or function) which allows to do this: ?php (True==False) or (construct_i_am_looking_for(unset($a))); ? Note that the unset() has no return value (and so it can't be used as a part of other expression; it can be only used as a stand-alone statement), so I thing it could be good if there were some construct which makes expression with return value from expression with no return value. It is not possible to use just ?php (True==False) or (unset($a)); ? I have read the whole front section of the PHP manual (and a lot of the rest) but haven't found a construct like that. Is there such a construct in PHP? If there is, what is its name? --Tomas_Tintera -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using constructs like unset() in expressions like ()()
Hi all. Is there some construct, which evaluates any type of its parameter (like t_echo, t_unset) and returns some value with normal type (like 0)? What? I would like to unset a variable in an operation like ()?unset():() and I can not use if because if does not return normal type of value (like 0 or 'a') and can not be used in operations like () (). Tomas Tintera -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php