简体   繁体   中英

Redirect cronjob to other page in PHP

Im struggling with a PHP script that is activated by a cronjob every minute. It needs to redirect the cronjob to another page wat triggers something else, but i cant get it to work.

In that PHP file there is an if else function where it checks something in the database. When it is the 'if', the cronjob needs to be redirected to another page where it triggers something else external.

A header doesnt work, the cronjob doesnt listened to that. I also tried the file_get_contents($url) method, but this also just doesnt work.

How can i realise this?

Try to use context argument of file_get_contents :

$context = stream_context_create(
    array(
        'http' => array(
            'follow_location' => true
        )
    )
);

$html = file_get_contents('http://www.example.com/', false, $context);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM