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();

"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.