Re: require/include using a class ...
| From: | (Mark Walter) | Date: | Tue, 25 Jul 2000 17:17:11 +0000 |
| Subject: | Re: require/include using a class ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12305@lists.php.net to get a copy of this message | ||
Hello Brian,
> <? include('class_mysql.php'); ?>
> Will also work. Technically, you want to use include() in conjunction with
> a conditional, and require() when it needs to be included regardless of the
> circumstances, but I have stopped using require() altogether. Maybe someone
> else will clarify. (more below)
I would like to create some classes to handle the sql-connects more comfortable
and so they need to be included regardless of the circumstances. As I understand
'require' is the best choice IMHO.
> I'm not sure what else you're going to include in this code, but you may
> want to make init() your constructor. In other words, give that method the
> same name as your class.
That's right but problem's came up as either require/include cocked up.
I solved the problem giving the file a new name. That's all for that.
I think it could haven been taken a long time to find this problem. So
it was right to ask here as FAQ's or the archive wouldn't really helped
me. Thanks for your cooperation.
> When you create a new instance of that class (see below), your constructor
> (the function (method) that has the same name as the class itself) will
> execute automatically.
> Remember that simply including or requiring a class in the header of your
> document won't automatically let you access its methods. You have to create
> a new object/instance/dohickey
Thanks for your help. I realized the way of creating objects. I think it's
very easy in opposite to perl or C++. Will going to make my luck these
days. : )
> include('class_mysql.php');
> $object = new mysql;
> $object->init();
Thank you, this would have been my next step. : )
cu
--
Mark-Walter@t-online.de