如何向soapVars添加属性

goo*_*orj 4 php soap

我想用这样的属性创建soapVars:

<tag attr="xxx">yyy</tag>
Run Code Online (Sandbox Code Playgroud)

这是否可以使用SoapVar构造函数,但使用XSD_ANYXML和原始xml字符串?

pcm*_*ind 5

最好的方法是:

<?php 
 $tag['_'] = 'yyy'; 
 $tag['attr'] = 'xxx'; 
 $tagVar = new SoapVar($tag, SOAP_ENC_OBJECT); 

?> 
Run Code Online (Sandbox Code Playgroud)

结果将是:

<tag attr="xxx">yyy</tag>
Run Code Online (Sandbox Code Playgroud)

  • 这给了我:`<tagVar> <_> yyy </ _> <attr> xxx </ attr> </ tagVar>` (23认同)
  • 你总是可以参考php.net :) (2认同)