Olivier Royo
Olivier Royo

Reputation: 840

New instance in a cronjob php

I want to execute a periodic task using a php script.

Inside my script (into my cron job), I am trying to instantiate a class without success:

The include works fine:

include_once (dirname(__FILE__).\'../my/class/MyObjectMgrClass.php\');

But as soon as I try to instantiate the class, the cron does not work anymore:

$myObjectMgr = new MyObjectMgr();

Upvotes: 0

Views: 165

Answers (1)

vnkomv
vnkomv

Reputation: 11

"include_once()" try to include the file you define but won't stop the script if it doesn't exists Try to use require_once(), it will trigger a fatal error if the file is missing. by the way when your concatenate with dirname, add and / to the begin of the string like

 require_once (dirname(__FILE__)). '/../my/class/MyObjectMgrClass.php';

Also don't use the \ unless you want to escape something.

Upvotes: 1

Related Questions