2017-06-05 46 views
0

我有以下捲曲POST請求

$Curl_Session = curl_init($url); 
     curl_setopt($Curl_Session, CURLOPT_POST, count($post)); 
     curl_setopt($Curl_Session, CURLOPT_POSTFIELDS, "login={$username}&password={$password}"); 
     curl_setopt($Curl_Session, CURLOPT_HTTPHEADER, $headers); 
     curl_setopt($Curl_Session, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($Curl_Session, CURLOPT_FOLLOWLOCATION, 1); 
     curl_setopt($Curl_Session, CURLOPT_SSL_VERIFYHOST, false); 
     curl_setopt($Curl_Session, CURLOPT_SSL_VERIFYPEER, false);  
     $request = curl_exec($Curl_Session); 

什麼是使用{}意味着什麼?此請求是否容易受到xss(我的意思是登錄名和密碼參數)?

它設置爲應用程序的類型的捲曲請求/ JSON

+0

檢查這個https://stackoverflow.com/questions/2596837/curly-braces-in-string-in-php –

+3

的可能的複製[ PHP中的字符串中的花括號](https://stackoverflow.com/questions/2596837/curly-braces-in-string-in-php) – castis

+0

表示將使用{}內的變量的值。閱讀更多關於:https://stackoverflow.com/questions/2596837/curly-braces-in-string-in-php – BDS

回答

0

http://php.net/manual/en/language.types.string.php

絡合物(捲曲)語法

這不叫複雜,因爲語法是複雜的,但是因爲它允許使用複雜的表達式。

任何具有字符串表示形式的標量變量,數組元素或對象屬性均可通過此語法包含在內。只需以與字符串外部相同的方式編寫表達式,然後將其包裝在{}中。由於{不能轉義,因此只有當$緊跟在{之後時纔會識別此語法。

是的,你使用它的方式很容易被注射。你最好通過POST字段的數組,像這樣:

curl_setopt($Curl_Session, CURLOPT_POSTFIELDS, ['login' => $username, 'password' => $password]; 
+0

感謝大家的回覆,並對不起,如果它是一個重複的問題.. 因此,有可能請求像我的例子可能容易受到sql注入或xss問題? –