Re: Using constructs like unset() in expressions like ()&&()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux