What is meaning of “<<”, “--” in perl and implementation in php?

后端 未结 2 1782
北海茫月
北海茫月 2021-01-23 07:19

I am converting some Perl code to PHP.
However, I do not know much about Perl, so I have to code it with a rough meaning.

And, I do not understand what the below P

2条回答
  •  臣服心动
    2021-01-23 08:02

    $req2->content(<<"POST_DATA"); #what means this?
    

    The <<"POST_DATA" starts a HERE document, which is essentially a long string. The double quotes "" tell Perl to do string interpolation. That means that variables inside the string will be replaced with their content. The string ends when the parser encounters the delimiter, which in this case is the string POST_DATA.

    The -- you are referring to is not an operator. It's used inside of the string. The program sends a multipart/formdata form over HTTP. Look at RFC 7578 if you are interested in the technical details. Essentially, each part of the request body represents one document. It can be multi-line and contain lots of information. The boundary can be set in the HTTP headers, and is typically a long, random string that would not appear in any of the body parts. See this answer for a more detailed explanation.

提交回复
热议问题