我想更新html中的div,每周只用PHP显示不同的内容,而不使用cron.
如何实现它?以下代码用于在第10天每2个月激活一次代码
但我猜逻辑会有所不同.如果可能的话,一些提示或示例将是伟大的!我很乐意听到你的消息!
如何实现它?以下代码用于在第10天每2个月激活一次代码
但我猜逻辑会有所不同.如果可能的话,一些提示或示例将是伟大的!我很乐意听到你的消息!
// check if current day is 10th and month is an even number if (date('d')==10 && date('m') % 2 == 0) { // get todays-date (format: yyyymmdd) $today = date('Ymd'); // get info about last run $last_run = variable_get('my_last_run',0); // check last run was not today if ($last_run!=$today) { // set last run to today variable_set('my_last_run',$today); /* Place your code here */ } }
解决方法
我刚刚更新了你的例子,现在它将在下周一发布:
$weekInYearNumber = (int)date('W'); $weekDayNumber = (int)date('w'); if ($weekDayNumber === 1 && $weekInYearNumber % 2 == 0) { // Rest of your code. }