You are here: Re: Getting the names of variables passed to functions « PHP Programming Language « IT news, forums, messages
Re: Getting the names of variables passed to functions

Posted by Tyno Gendo on 10/10/07 12:44

Tyno Gendo wrote:
> OR something like that....
>
> just curious why ;-)
>
> ... and now someone will point a really easy way to do it and as well
> and i'll look a fool... LOL

I noticed a few typos after I'd typed it into my email, cut and paste
into nusphere to see if it ran... so here is adjusted version with
corrected var names... I'm still curious.. why ? ;-)

class CVar {
protected $var_name = '';
protected $var_value = '';
public function __construct( $name = '', $value = '' ) {
$this->var_name = $name;
$this->var_value = $value;
}
public function getName() { return $this->var_name; }
public function getValue() { return $this->var_value; }
public function setName($name) { $this->var_name = $name; }
public function setValue($value){ $this->var_value = $value; }
}

function foo($bar) {
return $bar->getName();
}

$myvar = new CVar('animal','dog');
echo foo( $myvar );

 

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

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