如何在 CRON 中递增 PHP 变量
我有一个 simpleXML 文件,该文件是从 REST API 调用生成的,并将通过 cronjob 按计划输入数据库。
API 调用返回的结果限制为每页 10 个,我遇到的问题是更新调用的页码参数以获取下一组结果
$page_number = 1;
$page = $page_number++;
$api_url = "example.com/rest/api?products=new&pageid=$page";
我不确定如何让变量 $page 递增每个 cron,非常感谢任何帮助
I have a simpleXML file that is being generated from a rest api call and will be fed into a database on a scheduled basis via a cronjob.
The results returned from the API calls are limited to 10 per page and the problem I am having is updating the page number parameter for the call to get the next set of results
$page_number = 1;
$page = $page_number++;
$api_url = "example.com/rest/api?products=new&pageid=$page";
I'm not sure how to get the variable $page to increment on each cron, any help is much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以存储在:
socket
即可You could store in:
socket
for this.在 /tmp/file.txt 中创建新的空文件
make new empty file in /tmp/file.txt
将数字保存在数据库中或保存为仅包含数字作为内容的文件将是最安全的方法。
Saving the number in a DB Or as a file with only the number as content would be the safest way.
您可以轻松地使用任何其他数据库或缓存(
MySQL
、memcache
等)You could as easily use any another database or cache (
MySQL
,memcache
, etc.)