You are here: Re: how to check for a static call from an object « PHP « IT news, forums, messages
Re: how to check for a static call from an object

Posted by Sebastian Mendel on 07/21/05 12:21

Sebastian Mendel wrote:
> Hi,
>
> how can i check if a method is called statically when called from inside
> another object? (without debug_bactrace())
>
>
> class foo
> {
> function bar()
> {
> if ( isset( $this ) )
> {
> return 'not static';
> }
> return 'static';
> }
>
> function bar2() { foo::bar(); }
> }
>

sorry, my mistake

// returns 'static'
echo foo::bar();

// returns 'not static' but should be 'static'
$foo = new foo;
echo $foo->bar2();

> so, how can i prevent a method from called static or not called static?
>
> and btw. does anynone know why it is not good to let one function handle
> both mehtods of calling (static and not static) as in PHP 5 you will get
> notices if called wrong - but PHP doesnt support multiple
> function-definitions like:
>
> class foo
> {
> static function bar()
> {
> return ANY_DEFAULT_VALUE;
> }
>
> function bar()
> {
> return $this->value;
> }
> }
>
> or even
>
>
> class foo
> {
> static function bar( $param )
> {
> return $param;
> }
>
> function bar()
> {
> return $this->param;
> }
> }
>
> or is this at least an issue for the internals-list?
>


--
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

 

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

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