|
Posted by Martin Mandl - m2m tech support on 03/08/07 09:21
On Mar 8, 4:46 am, Hendri Kurniawan <ask...@email.com> wrote:
> Giacomo wrote:
> > Hi all.
> > I just don't understand the behaviour of this: i have a few-webpages
> > application in which I have these two files (and all the others)
>
> > classes/class.User.php
> > include/stdinclude.php
>
> > the code of stdinclude.php is the following:
>
> > <CODE>
> > ...
> > session_start();
>
> > function __autoload( $classname ) {
> > require_once "../classes/class.$class_name.php";
> > }
> > ...
> > </CODE>
>
> > I was getting the require_once-fatal-error becouse the script couldn't
> > find "../classes/class.User.php", and I tried to understand where the
> > include path pointed to: so i dumped the stacktrace and that's what
> > was in:
>
> > this never happends to me before; is this a correct php behaviour ?
> > should I fix with an absolute path ?
>
> > tnx, bye
> > M
>
> Try using dirname(__FILE__).
> So: require_once dirname(__FILE__)."/../classes/class.$class_name.php";
>
> Hendri
Dear Giacomo,
the path for require_once() is relative to the initial file, e.g.
1) dummy.php -> include('include/stdinclude.php');
2) include/stdinclude.php -> require_once('classes/
class.User.php'); // path is relative to dummy
3) classes/class.User.php
I hope that helped
Martin
------------------------------------------------
online accounting on bash bases
Online Einnahmen-Ausgaben-Rechnung
http://www.ea-geier.at
------------------------------------------------
m2m server software gmbh
http://www.m2m.at
Navigation:
[Reply to this message]
|