php的file_get_contents函数抓取的url中获取当天日期应该怎么写

2025-03-01 04:36:40
推荐回答(4个)
回答1:

写法错了,这样只是一个字符串,date()并没有生效而且用法也不对
$dTime = date("Y-m-d",time());
file_get_contents('http://baidu.lecai.com/lottery/draw/list/22?d='.$dTime );

回答2:

php的file_get_contents函数在获取url时,那个url应该怎么拼接,只能把参数放到最后吗,中间的参数可以自定义吗,要怎么写?

回答3:

你是不是可以把整个的url拿出来,正则匹配啊?file_get_contents函数好像不能直接拿你需要得到值吧?
/([0-9]{4}-[0-9]{2}-[0-9]{2})/

回答4:

你引号打错位置了吧
file_get_contents('http://baidu.lecai.com/lottery/draw/list/22?d='.date("Y-m-d"));