Reply to Re: PHP 5 Re-assign $this PROBLEM - any ideas?

Your name:

Reply:


Posted by Wayne on 02/16/06 20:48

On Thu, 16 Feb 2006 09:33:49 +0200, "Ryan White" <ryan@trigger.co.za>
wrote:

>Things work fantastically under php4, but I know that when I swap over to
>php5, it's going to throw a hissy fit, because reassigning $this is not
>allowed.
>
>Aside from going around the Message class, and just starting messages of a
>particular type from scratch:
>
>Is there some sort of cunning retro-fit I could do to the Message class, so
>I don't have to trawl through thousands of lines of code?

Use a factory method. Declare a public static method in the messaging
class that creates the appropriate type:

class Messge {
public static function factory($msgType) {
... return the correct type here ...
}
}

Then just do a search & replace of all your 'new Message(' code and
replace it with 'Message::factory('...

[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

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