Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php循环中运行url_Php - Fatal编程技术网

如何在php循环中运行url

如何在php循环中运行url,php,Php,假设我有一个php循环,如下所示: while($row = mysql_fetch_array($result)){ $phones = $row['phone']; $text = $row['message']; $url = 'http://abcwebsite.com/user.php? '&mobileno=' . $phones . '&message=' . $text; } 这就是在循环中运行url直到循环完成的方法吗?您可以使用数组

假设我有一个php循环,如下所示:

while($row = mysql_fetch_array($result)){    
  $phones = $row['phone'];
  $text   = $row['message']; 
  $url = 'http://abcwebsite.com/user.php? '&mobileno=' . $phones . '&message=' . $text;
}

这就是在循环中运行url直到循环完成的方法吗?

您可以使用数组收集所有url:

比如:$url=array()

可以在循环内使用$url

    $i = 0;
    $url = array();
      while($row = mysql_fetch_array($result)){    
            $phones = $row['phone'];
            $text   = $row['message']; 
            $url[$i] = 'http://abcwebsite.com/user.php? '&mobileno=' . $phones . '&message=' . $text;
            $i++;
    }

然后,您可以使用数组
$url
,它包含所有url。

什么意思,运行url?尝试
文件获取内容($url)
?您知道您的代码在PHP 7(PHP的未来版本)中不起作用吗?
mysql\u*
函数很久以来就被弃用了?但是如何执行url..我使用了header()函数,但它只在只获取一行时起作用。