PUT/DELETE data is lost after 5 requests

I'm simply trying to do PUT/DELETE requests in my PHP application, but after the first 5 requests, the data is lost. I've reduced the code to this to illustrate the issue: index.php $h = fopen('php://input', 'r'); var_dump(fread($h, 1024)); die(); CLI input curl -X PUT http://cms.dev.com -d '{"foo":"bar"}' So, for the first 5 times I run that, I get: string(13) "{"foo":"bar"}" T

PUT / DELETE数据在5次请求后丢失

我只是试图在我的PHP应用程序中执行PUT / DELETE请求,但在前5次请求后,数据丢失。 为了说明这个问题,我将代码简化为: 的index.php $h = fopen('php://input', 'r'); var_dump(fread($h, 1024)); die(); CLI输入 curl -X PUT http://cms.dev.com -d '{"foo":"bar"}' 所以,在我运行的前5次,我得到: string(13) "{"foo":"bar"}" 然后,从6日起,我得到: string(0) "" 我正在运行PHP版本5.6.0beta1和Apache / 2.

Laravel 5.2 different routing types

I'm new to Laravel but learning fast. The documentation about Routing says the following: Route::get($uri, $callback); Route::post($uri, $callback); Route::put($uri, $callback); Route::patch($uri, $callback); Route::delete($uri, $callback); Route::options($uri, $callback); I can code in PHP and know what POST and GET requests are. And also know how to update and delete records via SQL. B

Laravel 5.2不同的路由类型

我是Laravel的新手,但学得很快。 有关路由的文档说明如下: Route::get($uri, $callback); Route::post($uri, $callback); Route::put($uri, $callback); Route::patch($uri, $callback); Route::delete($uri, $callback); Route::options($uri, $callback); 我可以用PHP编写代码并知道POST和GET请求是什么。 还知道如何通过SQL更新和删除记录。 但为什么有这么多的路由类型,不是POST和GET足够? 在哪种情况下我应该使

URL design for advanced filtering of results in restful API

Let's take a generic example of resources you might model with a restful API built in PHP. A garage has multiple cars and multiple mechanics. A car has only one garage. A mechanic has multiple cars and multiple garages (he's a workaholic ok!). So logic says that our endpoints should be /v1/garages /v1/garages/1234 /v1/mechanics /v1/mechanics/1234 /v1/cars /v1/cars/1234 If we w

用于高级过滤静默API结果的URL设计

我们来举一个你可能使用PHP中建立的restful API建模的资源的通用例子。 车库有多辆汽车和多种机械装置。 一辆车只有一个车库。 一个机械师有多辆车和多个车库(他是一个工作狂还行!)。 所以逻辑说,我们的终点应该是 /v1/garages /v1/garages/1234 /v1/mechanics /v1/mechanics/1234 /v1/cars /v1/cars/1234 如果我们想要获得1234车库的所有车辆,我们将使用GET /v1/garages/1234/cars 如果我们想要所有在修理厂

How to check if someone connected via IPv6 / IPv4

I want to check via php if someone connects to my site via IPv4 or IPv6. The client address can be found in $_SERVER["REMOTE_ADDR"] but how to check if it's IPv4 or IPv6 ? Check for IPv4 $ip = "255.255.255.255"; if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { echo "Valid IPv4"; } else { echo "Invalid IPv4"; } Check for IPv6 $ip = "FE80:0000:0000:0000:0

如何检查是否有人通过IPv6 / IPv4连接

如果有人通过IPv4或IPv6连接到我的网站,我想通过php检查。 客户端地址可以在$_SERVER["REMOTE_ADDR"]找到, 但是如何检查它是IPv4还是IPv6? 检查IPv4 $ip = "255.255.255.255"; if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { echo "Valid IPv4"; } else { echo "Invalid IPv4"; } 检查IPv6 $ip = "FE80:0000:0000:0000:0202:B3FF:FE1E:8329"; if(filter_var($ip, FILTER_VALI

How to get last key in an array?

我怎样才能得到数组的最后一个键? A solution would be to use a combination of end and key (quoting) : end() advances array 's internal pointer to the last element, and returns its value. key() returns the index element of the current array position. So, a portion of code such as this one should do the trick : $array = array( 'first' => 123, 'second' => 456, 'last' =>

如何获得数组中的最后一个键?

我怎样才能得到数组的最后一个键? 解决方法是使用end和key (引用)的组合: end()数组的内部指针前进到最后一个元素,并返回它的值。 key()返回当前数组位置的索引元素。 所以,像这样的代码的一部分应该诀窍: $array = array( 'first' => 123, 'second' => 456, 'last' => 789, ); end($array); // move the internal pointer to the end of the array $key = key($array); // fetche

How to strip all spaces out of a string in php?

Possible Duplicate: To strip whitespaces inside a variable in PHP How can i strip / remove all spaces of a string in PHP? I have a string like $string = "this is my string"; the output should be "thisismystring" How can i do that? Do you just mean spaces or all whitespace? For just spaces, use str_replace: $string = str_replace(' ', '', $string); For all whitesp

如何去除一个字符串在PHP中的所有空间?

可能重复: 在PHP中去除变量内的空格 我怎么能剥夺 / 删除 PHP 字符串的所有空间 ? 我有一个字符串像$string = "this is my string"; 输出应该是"thisismystring" 我怎样才能做到这一点? 你只是指空格或所有空格? 对于空格,使用str_replace: $string = str_replace(' ', '', $string); 对于所有空白,请使用preg_replace: $string = preg_replace('/s+/', '', $string); (从这里)

Using a front end editor with static pages plugin

Im really new to ocms, I have installed static pages and its working really good. I want to edit the fields from the front page (in context editing) with one of the plugins, this for example: https://octobercms.com/plugin/netsti-editor I have dragged to my layout page, but I can't edit this in the front page. this is an example how I use the static page plugin: <img src="{mediafinder na

使用静态页面插件的前端编辑器

我真的很新的ocms,我已经安装了静态页面,其工作非常好。 我想用其中一个插件编辑头版中的字段(例如在上下文编辑中),例如:https://octobercms.com/plugin/netsti-editor我已经拖动到我的布局页面,但是我可以'不要在头版中编辑它。 这是我使用静态页面插件的一个例子: <img src="{mediafinder name="logo" label="Logo" tab="General" mode="image"}{/mediafinder}" /> {repeater name="side_logos" tab="Gen

optimization worth the time?

I am a PHP developer and I have always thought that micro-optimizations are not worth the time. If you really need that extra performance, you would either write your software so that it's architecturally faster, or you write a C++ extension to handle slow tasks (or better yet, compile the code using HipHop). However, today a work mate told me that there is a big difference in is_array($ar

优化值得的时间?

我是一名PHP开发人员,我一直认为微型优化不值得。 如果你真的需要额外的性能,你可以编写你的软件,以便体系结构更快,或者编写一个C ++扩展来处理缓慢的任务(或者更好的是,使用HipHop编译代码)。 然而,今天的一位同事告诉我说,这有很大的不同 is_array($array) 和 $array === (array) $array 我真的很喜欢“呃,这实在是毫无意义的比较”,但他不同意我的观点。他是我们公司最好的开发人员,并负责一个每天处理大约50

How to find the closest value in PHP

How to determine the RESULTS field in table users, base on USER SCORE field with the provisions of the value closest to SCORE BRAND field. This is table Brand <table> <tr> <th>BRAND NAME</th> <th>SCORE BRAND</th> </tr>"; $sql = mysql_query("SELECT * FROM brand"); while($m=mysql_fetch_array($sql)){ echo "<tr> <td>$m[brand_name]</td&

如何在PHP中找到最接近的值

如何根据USER SCORE字段以及最接近SCORE BRAND字段的值的规定来确定表用户中的RESULTS字段。 这是餐桌品牌 <table> <tr> <th>BRAND NAME</th> <th>SCORE BRAND</th> </tr>"; $sql = mysql_query("SELECT * FROM brand"); while($m=mysql_fetch_array($sql)){ echo "<tr> <td>$m[brand_name]</td> <td>$m[score]</td><tr>"; } </table

foreach changes in PHP7

foreach in PHP7 by default, when iterating by value, operates on a copy of the array according to: http://php.net/manual/en/migration70.incompatible.php Does it lazily create a copy only if there are changes made to the array or a value or will it always make a copy and in essence make looping over references a performance optimization? Also, do arrays of objects still loop over/give you refe

在PHP7中进行每次更改

默认情况下,PHP7中的foreach按值迭代时,按照以下网址对数组副本进行操作:http://php.net/manual/en/migration70.incompatible.php 只有在对数组或值做了修改时,它才会懒散地创建副本,还是会始终创建一个副本,并且本质上是循环引用性能优化? 此外,对象数组仍然循环/给你的对象的引用? 或者他们是否也会为foreach创建副本并按值返回对象? 在PHP 7中,如果按值迭代数组,则只有在数组实际被修改时才会延迟复制副本