dongxueji2838
dongxueji2838
2016-05-21 07:12
浏览 48

这个PHP行的含义是什么?<<< XML <! - xml标签在这里 - > XML'我可以;似乎解析这个权利

I have this php line in magento rest api for inserting a product image. It works but I need to know whats happening because it causes error sometimes parsing. thanks

$xmlstr = <<<XML
<magento_api>
<file_mime_type>image/jpeg</file_mime_type
<file_content>iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWtJREFUeNpi/P//P8NgBkwMgxyMOnDUgTDAyMhIDNYF4vNA/B+IDwCxHLoakgEoFxODiQRXQUYi4e3k2gfDjMRajsP3zED8F8pmA+JvUDEYeArEMugOpFcanA/Ef6A0CPwC4uNoag5SnAjJjGI2tKhkg4rLAfFGIH4IxEuBWIjSKKYkDfZCHddLiwChVhokK8YGohwEZYy3aBmEKmDEhOCgreomo+VmZHxsMEQxIc2MAx3FO/DI3RxMmQTZkI9ALDCaSUYdOOrAIeRAPzQ+PxCHUM2FFDb5paGNBPRa5C20bUhxc4sSB4JaLnvxVHWHsbVu6OnACjyOg+HqgXKgGRD/JMKBoD6LDb0dyAPE94hwHAw/hGYcujlwEQmOg+EV9HJgLBmOg+FMWjsQVKR8psCBoDSrQqoDSSmoG6Hpj1wA6ju30LI9+BBX4UsC+Ai0T4BWVd1EIL5PgeO+APECmoXgaGtm1IE0AgABBgAJAICuV8dAUAAAAABJRU5ErkJggg=
</file_content>
<file_name>test</file_name>
</magento_api>
XML;                

图片转代码服务由CSDN问答提供 功能建议

我在magento rest api中有这个用于插入产品图片的php行。 它有效,但我需要知道发生了什么,因为它有时会导致错误解析。 感谢

 <代码> $ xmlstr = LT;&LT;&LT; XML 
&LT; magento_api&GT; 
&LT; file_mime_type&GT;图像/ JPEG&LT; / file_mime_type 
&LT; FILE_CONTENT&GT; iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM / rhtAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWtJREFUeNpi /  P // P8NgBkwMgxyMOnDUgTDAyMhIDNYF4vNA / B + IDwCxHLoakgEoFxODiQRXQUYi4e3k2gfDjMRajsP3zED8F8pmA + JvUDEYeArEMugOpFcanA / Ef6A0CPwC4uNoag5SnAjJjGI2tKhkg4rLAfFGIH4IxEuBWIjSKKYkDfZCHddLiwChVhokK8YGohwEZYy3aBmEKmDEhOCgreomo + VmZHxsMEQxIc2MAx3FO / DI3RxMmQTZkI9ALDCaSUYdOOrAIeRAPzQ + PxCHUM2FFDb5paGNBPRa5C20bUhxc4sSB4JaLnvxVHWHsbVu6OnACjyOg + HqgXKgGRD / JMKBoD6LDb0dyAPE94hwHAw / hGYcujlwEQmOg + EV9HJgLBmOg + FMWjsQVKR8psCBoDSrQqoDSSmoG6Hpj1wA6ju30LI9 + BBX4UsC + Ai0T4BWVd1EIL5PgeO + APECmoXgaGtm1IE0AgABBgAJAICuV8dAUAAAAABJRU5ErkJggg = 
&LT; / FILE_CONTENT&GT; 
&LT; FILE_NAME&GT;试验&LT; / FILE_NAME&GT  ; 
&LT; / magento_api&GT; 
XML;  
   
 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongyanjing5975
    dongyanjing5975 2016-05-21 07:19
    已采纳

    It's heredoc syntax - the lines between <<<XML and XML; are treated as a string value.

    It can be useful if you want to ignore quotation issues (mixed ' and ") and is often picked up by syntax highlighting (TXT, SQL, HTML are also common identifiers.)

    Parsing errors are often caused by ignoring the following warning:

    It is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is on UNIX systems, including Mac OS X. The closing delimiter must also be followed by a newline.

    点赞 评论

相关推荐