Re: class calling script
| From: | Jason Barnett | Date: | Tue, 12 Apr 2005 14:09:16 +0000 |
| Subject: | Re: class calling script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-212915@lists.php.net to get a copy of this message | ||
php@electroteque.org wrote:
> Hi there, I have been testing a possible solution to reduce the ammount of
> interface calling scriptsto my class files. Currently each class has a calling script. I am
For PHP5 you can try __autoload(). It provides for you a last-chance /
just in time loading of a class file. The main drawback of using this
is that there is (currently) only one __autoload() function allowed, but
this limitation should be removed once PHP5.1.0 gets rolled out.
> thinking of setting up a url like /currentdir/packagename/classname, mind you this is only a
> test but is it a
> good or bad bad idea ?I have run into troubles getting get queries because its calling the
> classname in the query alreadyso /packagename/classname?test=1 doesnt work.
>
Using rewrite rules would be another way you could do it. Or you could
have one "main" include file that would set some variable (call it
$base_dir) that points to the filesystem folder that is your root
directory. I.e.
<?php
/** "main" include file */
$base_dir = dirname(__FILE__) . '/';
/** now include some other global classes relative to this $base_dir */
include_once ($base_dir . 'path/from/docroot/to/class.php');
?>
<?php
/** some other script loads main config file */
require_once '/path/to/main.php';
/** now get your required classes */
require_once $base_dir . 'path/to/some/class.php';
?>
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc