You are here: Re: crontab and the include() function « PHP Programming Language « IT news, forums, messages
Re: crontab and the include() function

Posted by Vladimir Ghetau on 06/17/07 13:59

On Jun 15, 2:17 pm, berksh...@gmail.com wrote:
> On Jun 14, 12:51 pm, Vladimir Ghetau <vladi...@pixeltomorrow.com>
> wrote:
>
>
>
> > On Jun 14, 3:49 pm, berksh...@gmail.com wrote:
>
> > > We recently upgraded php from 4.3.9 to 4.4.7. Everything is working
> > > well, except the php scripts running as cronjobs. It appears the
> > > problem is that these scripts utilize the include() function and these
> > > functions are utilizing relative paths. They worked just fine with
> > > the old version of php, but not with the new version.
>
> > > Anyone know what is causing this hiccup?
>
> > > TIA
>
> > Try using the server relative path in this case, or check the PHP.ini
> > and setup some paths in there.
>
> > So, instead of
>
> > <?php
>
> > include ('whatever.php');
>
> > ?>
>
> > try
>
> > <?php
>
> > include('server/relative/path/to/the/whatever/file.php');
>
> > ?>
>
> > Cheers,
>
> > Vladimir Ghetau
>
> Vladimir,
>
> Thanks for th reply. Unfortunately there are quite a few includes,
> and those includes have includes as well so changing hte include path
> from relative paths to absolute paths isn't a practical option for us
> at the momemnt.




Hey B,

How about defining a named constant, let's call it MY_SCRIPT_ROOT,
that contains the closest path to your script, let's say

<?php

define('MY_SCRIPT_ROOT', '/dev/myscript');



?>

and then, all the includes will go like this:



<?php

// an include for the /dev/myscript/includes/classes/php/
bingoclass.php


include (MY_SCRIPT_ROOT .'/includes/classes/php/bingoclass.php');


// an include for /dev/myscript/doit.php

include (MY_SCRIPT_ROOT .'/doit.php');


// an include for /dev/myscript/abc/yep.php

include (MY_SCRIPT_ROOT .'abc/yep.php');

?>


This is the best approach when you're dealing with strange paths that
go on different levels and I'm using it with success.


Vladimir

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация