Reply to Re: Functions for variables

Your name:

Reply:


Posted by Janwillem Borleffs on 04/02/06 16:57

paladin.rithe@gmail.com wrote:
> I seem to recall seeing an article somewhere about how to easily make
> functions that just set the variables. I have no idea where that was,
> or what to look for.
> I think it defined one function, that set the variable that was named.
> So, if I called joe(40), it would set $joe = 40; jane(60) would set
> $jane=60. And they both would use the same function, template() let's
> say.
> Does someone know where that article is, or how to do this? Thanks.
>

In PHP5 you could do something like the following:

<?php

class SetVar {
function __call($f, $n) {
global $$f;
$$f = $n[0];
}
}

$joe = '';
$setVar = new SetVar;
$setVar->joe(1);
print $joe;

?>

But, as Oli already asked, why would you want to do this?


JW

[Back to original 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

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