You are here: Re: getting the variable name in php « PHP Programming Language « IT news, forums, messages
Re: getting the variable name in php

Posted by Janwillem Borleffs on 06/02/05 17:25

Ewoud Dronkert wrote:

> On Thu, 02 Jun 2005 13:09:31 +0100, James wrote:
>
>>Someone has wrote some info on how to do this here, as a user
>>contributed note: http://php.net/variables
>>[...] credit goes to lucas karisny.
>
>
> Yeah. If you have no need for local scope you can trim the function a
> little. Also with simpler unique value generation:
>
> function f( &$x )
> {
> $old = $x;
> $x = md5( uniqid( mt_rand(), TRUE ) );
> foreach ( $GLOBALS as $k => $v )
> if ( $v === $x )
> {
> $x = $old;
> return $k;
> }
> return FALSE;
> }
>
> $a = 'test';
> $b = 'test';
> echo f( $a ); // 'a'
> echo f( $b ); // 'b'
>
>

$x should be assigned its old value before returning FALSE; otherwise it
will be modified when the function failed...


JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация