Reply to Re: classes and require ?

Your name:

Reply:


Posted by Jerry Stuckle on 03/12/07 14:50

avlee wrote:
> Hello
>
> I have a big class in one php file.
> I would like to divide it to many smaller files. But when i try:
>
> <?php
>
> class IndexController extends Zend_Controller_Action
> {
> require_once('IndexController_common.php');
> require_once('IndexController_client_car.php');
>
> i receive parse error:
> "Parse error: syntax error, unexpected T_REQUIRE_ONCE, expecting
> T_FUNCTION in
> /mnt/hda5/www/zend/dg/car/application/controllers/IndexController.php on
> line 6"
>
> When i move require_once outside class definition everything works fine.
> But i need require inside
> of class because in thouse files are functions which are the member of
> that class.
> How can i do it ?
>
> Thanx

They're executable statements, so they need to be in a function (or
global). And you can't put them in the constructor as Henrik indicated
or you would be including them in the constructor itself.

But if they're members of the class, I would suggest you just keep them
all in one file. That's what I do. After all - you're going to include
them anyway. Better to include from one file than 10.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[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

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