[Record:IT][PHP] GET / POST tag name syntex for PHP5.2.x & PHP5.6.x

TN.HK
Messages From Irresponsible Fat Boy
2 min readAug 8, 2021

用了自家維護的小型伺服器(運行php5.6.x)來為公司架構網絡服務有兩年多了,仍在租用的網頁伺服器(運行php5.2.x)也沒維護多時了,但有同事要求一些新的服務時,想到有點資料必需要兩邊伺服器交換處理,便試試設定CORS(Cross-Origin Resource Sharing 跨來源資源共用),看看能否使用。
為測試,兩邊伺服器均有兩個PHP檔案,一個是用來輸入資料和發送要求到另一邊伺服器的input.php,另一個是處理了接收到由input.php送來的資料後發送回結果的return.php。
兩邊的return.php是一樣的,兩邊的input.php基本相同,只是發送的目的地不同而已。
在多次測試後,發現由自家伺服器送出的要求並沒有得到租用伺服器的回應,但反之則成功無誤。
在一個多小時的嘗試,看看程式碼有否問題、看看伺服器的設定有否問題等等,但,沒有喜色⋯⋯
小休片刻,腦部清晰了點,哎,嘩,唉⋯⋯ DLLM
原因找到了,是怠惰⋯⋯ 「脳が、震える」
要得到由GET所傳來的資料會用$_GET[‘tagname’]來讀取,但忘了由何時開始,發現用$GET[tagname]也可以讀取,就如在自家伺服器讀取資料庫物件矩陣時($row[tagname]而不是$row[‘tagname’]),我所有程式碼中的「 ’ ’ 」全到不翼而飛了⋯⋯
好,好了,是我的錯,以後會加回「 ’ ’ 」了!😕

Since using self-maintenance server (php5.6.x) to hosting some service for more than 2 years, the website hosted on rental hosting (php5.2.x) haven’t be update for long time, but wanna try CORS to transfer data between these two servers for some new services requested by colleagues, two pages had been writen and saved in both servers for the test .
The two pages are:
[input.php]: data input, submit to remote server for request return value by $.get; and
[return.php]: read the data send from client(?) server by GET and return to client(?) server.
The return.php are the same for both servers, and the only difference of the return.php for each server is the request URL.
After tried serval time, the rental hosting site did not return the value as the request had been sent from self-maintenance server, but the other direction is work fine.
With about an hour of checking the code, the setting, etc, no luck to solve….
Take a break, refresh the mind, well……. F___K
The problem is …… lazy!
In the past, getting the value from get, $_GET[‘tagname’] should be use, but a bit time ago, since I found that $_GET[tagname] can also get the value as pulling value from database-object-array ($row[tag] instead of $row[‘tag’]) with coding on my self-maintenance server, the quote symbol was always omitted from my codes…..
My…… That’s fine, I know it was my fault, I will use the quote to quote the tag 😕

[TN-20210808]

--

--

TN.HK
Messages From Irresponsible Fat Boy

Record and share something that are found interesting when roaming at the internet or real life!