Reply to Re: php 4.4.1 constructor Vs. Php 5.0 constructor

Your name:

Reply:


Posted by Andy on 12/07/05 11:57

It's true that PHP4 requires a constructor to have the same name as the
class, but that doesn't mean you have to upgrade to PHP5 just to use
the __construct method. Simply add a new method to you class with the
same name as the class and use that to call the __construct method.

Something like this should work:

class MyClass
{
function __construct($foo, $bar)
{
echo $foo, $bar;
}

function MyClass()
{
$args = func_get_args();
call_user_func_array(array(&$this, '__construct'), $args);
}
}

Andy

[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

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