在其他php文件中执行函数

I have a custom php unit that runs through a cronjob daily. I use this unit to make it easier to create new scheduled jobs. I use them to build my XMLTV guide.

I wrote a function create_guide ($id) which uses the id to find the configuration for the guide from the database. I use these configurations so i can have multiple guides made by one script.

Now i can use the shell_exec() and exec() to run scripts, but how can i use exec() to run the function create_guide($id) and pass the id? I have used CURL to execute scripts before, but there should be a nicer/better way to run these scripts wihout CURL?

Sounds like you just need to include the PHP file that contains the create_guide($id) function in it. If this file is just a file that contains a bunch of functions or a class then this should work.

Like so:

cronjob.php

<?php

require 'path/to/create_guide.php';

//rest of cron job code.

$data = create_guide($id);

?>