Reply to Re: Static method vs Non Static method

Your name:

Reply:


Posted by Chung Leong on 05/27/06 01:31

Oli Filth wrote:
> Hmm, I'd never thought about it like that. You're right of course.
> However, this logic applies to any use of a function/member/method at
> any point. Any time a symbol is used, PHP presumably has to interrogate
> some kind of symbol table to find whether that symbol exists in the
> current scope, and is legal.

Well, you would have to travel up the hierarchy to see if $this is
descended from the class. Not terribly expensive, but sort of pointless
given that the code would blow out anyway as soon as $this is accessed.
And if there's a check, you can't use such nice construct as this:

class A {
private $a = "Hello world";

public function Test() {
echo $this->a;
}
}

class B {
public $a = "The end is near";

public function Test() {
A::Test();
}
}

$b = new B();
$b->Test();

Totally unorthodox, but useful in some situations.

> Political connotations aside ( :) ), it's this kind of nonsense that
> makes me never want to use PHP again, at times! I know that some people
> see this as a useful "feature", but coming from a compiled-language
> background, I see this only as a development nightmare, and a massive
> limitation on language strictness, as you've already commented on...
> (Just in case; yes, I know that PHP isn't the only language that does this.)

One has to make a distinction between different environments though.
With PHP, you can very quickly see the result of a script. If there's a
bug in the code, it's usually quite obvious. You don't really need
warning from the compiler as much compared to a large C++ program.

[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

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