|
Posted by Giacomo on 03/08/07 10:44
On 8 Mar, 10:21, "Martin Mandl - m2m tech support"
<martin.ma...@gmail.com> wrote:
> 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
>
Thanks everybody.. i was confused by the fact the if i do this it
works:
1) dummy.php -> include('include/stdinclude.php');
2) include/stdinclude.php -> require_once('bar.php');
3) include/bar.php
... and of course by the fact that it was 2.00 am o'clock ;)
thanks
bye
M'
[Back to original message]
|