Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.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 在API端点仍在运行时将反馈返回给它_Php_Laravel_Api_Curl_Endpoint - Fatal编程技术网

Php 在API端点仍在运行时将反馈返回给它

Php 在API端点仍在运行时将反馈返回给它,php,laravel,api,curl,endpoint,Php,Laravel,Api,Curl,Endpoint,我有一个简单的API http://site/api/script/start?account=5000 它只是一个脚本,可以在我的数据库中创建5000个帐户 当我点击那个API时,这段代码会运行 $add = 0; for ($i = 0; $i < $account_total; $i++) { $max_id = 0; $account_id = $max_id+1; $url = env('API_HOST').'vse/account';

我有一个简单的API

http://site/api/script/start?account=5000

它只是一个脚本,可以在我的数据库中创建5000个帐户

当我点击那个API时,这段代码会运行

$add = 0; 

for ($i = 0; $i < $account_total; $i++) {
    
    $max_id = 0;
    $account_id = $max_id+1;
    $url = env('API_HOST').'vse/account';

    $json = '{"account_id":'.$account_id.',"email_address":"'.$type.$account_id.'@benu.com","password":"benu123","account_type":"customer","name_prefix":"","first_name":"'.strtoupper($type).'","middle_names":"","last_name":"'.$account_id.'","name_suffix":"","non_person_name":false,"DBA":"","display_name":"","address1":"","address2":"","address3":"","city":"Boston","state":"MA","postal_code":"02115","nation_code":"USA","phone1":"723487432","phone2":"","phone3":"","time_zone_offset_from_utc":-5,"customer_type":"'.$customer_type.'","longitude":0,"latitude":0,"altitude":0}';
    CURL::post($url,$json);

    echo $add++;
}
$add=0;
对于($i=0;$i<$account\u total;$i++){
$max_id=0;
$account\u id=$max\u id+1;
$url=env('API_HOST')。'vse/account';
$json='{“account_id:”.$account_id.“,”email_address:“.$type.$account_id.@benu.com”,“password:“benu123”,“account_type:”customer”,“name_prefix:”,“first_name:”.strotupper($type),“middle_name:”,“last_name:“.$account_id.”,”,“name后缀:”,“non_-person_-name:”false,“DBA:“display_-name:”,“address1:“address2:“address3:”,“城市”:“波士顿”,“州”:“MA”,“邮政编码”:“02115”,“国家编码”:“美国”,“电话1”:“723487432”,“电话2”:“电话3”:“时区与utc的偏移量”:-5,“客户类型”:“.$customer类型”。”,“经度”:0,“纬度”:0,“海拔”:0}”;
CURL::post($url,$json);
echo$add++;
}
代码运行得很好。帐户被添加了,但是当我尝试时

反馈,好像正在添加帐户

它看起来就像这样


我在想 如果有方法返回添加时的帐户增量

我试图添加
echo$add++;

它似乎不起作用

一个人怎样才能继续并取得这样的成就呢?

试试看

flush();
之后

echo $add++;

上面没有
ob\u start()
?如果在浏览器中而不是在rest客户端中请求脚本(这看起来是什么样子)也一样吗?
ob\u start()
会去哪里?在我的文件顶部还是在我的函数顶部?可以
ob\u start()
实现我正在尝试的操作吗?不,ob\u start()会阻止你想要的。所以我只是猜测,因为我还不知道是什么原因造成的…它不起作用。我仍然等到最后,然后在最后打印所有的点。也许是ob_flush();