Re: class calling script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



php@xxxxxxxxxxxxxxxx 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: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux