PHP接收前端傳值各種情況整理

2021-09-10 01:51:28 字數 1915 閱讀 7016

header('access-control-allow-origin:*');

var_dump($_post);

exit;

$.post('', , function(data, status) );
結果:

array(1)
**:

$.post('', , function(data, status) );
結果:

array(1)
$.post('', , function(data, status) );
結果:

array(1)
$.post('', , function(data, status) );
結果:

array(0)
$.post('', , function(data, status) );
結果:

array(0)
$.post('', 

}, function(data, status) );

結果:

array(0)
$.post('', ,

"test2": {}

}, function(data, status) );

結果:

array(0)
$.post('', ,

"test2":

}, function(data, status) );

結果:

array(1) 

}

$.post('', ]

}, function(data, status) );

結果:

array(0)
$.post('', ]]

}, function(data, status) );

結果:

array(0)
$.post('', , function(data, status) );
結果:

array(1)
$.post('', , function(data, status) );
結果:

array(1)
$.post('', , function(data, status) );
結果:

array(1)
用抓包工具發現

http請求裡面並不會傳送"無效的"字段——和{},所以不是php丟棄了,而是沒收到;

當傳的值是js裡的null,會轉換成空字串,http請求裡面是test=,所以php接收到的test是個空字串;

http協議不能表示值是什麼型別,所以php只能什麼都當做string

php對於接收到的每乙個值,會轉換成字串變數

php對於接收到的,之所有會接收不到是因為被一系列規則過濾掉了

以上結論是在jq和php7之下驗證的,其他環境不一定保證正確,之後可以試驗使用curl傳送資料試試。

PHP接收前端各種bug傳值整理

header access control allow origin var dump post exit post function data,status 結果 array 1 post function data,status 結果 array 1 post function data,sta...

前端 頁面跳轉 路由帶引數的各種情況

新頁面跳轉,且url的引數必傳,如果缺少引數頁面空白,不顯示內容。let routeurl this.router.resolve 有多個的話就繼續按照這個格式拼接 window.open routeurl.href,blank 第二個值決定的 後面會講本頁面跳轉跳轉的新頁面取值方法 mounted...

前端傳值後端接收不到 前端架構模式 支援前端的後端

英文 譯文 它是什麼?後端到後端的體系結構模式描述了乙個世界,其中每個客戶端應用程式都有自己的伺服器端元件 特定前端的後端。如果您有多個具有完全不同需求且都消耗相同基礎資源的客戶端介面,則此模式非常適用。現實世界中最常見的示例是同時具有web和移動客戶端的應用程式。要了解為什麼 後端對前端 有用,讓...