代码如下:

private function transmitText($object, $content)
{
    $textTpl = "<xml>
                <ToUserName>%s></ToUserName>
                <FromUserName>%s></FromUserName>
                <CreateTime>%s</CreateTime>
                <MsgType>%s</MsgType>
                <Content>%s></Content>
                </xml>";
    $result = sprintf($textTpl, 'ToUserName', 'FromUserName', time(), 'text','Content');
    return $result;
}

替换后打印$result如图:
php中xml变量替换

相关文章:

  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2022-12-23
猜你喜欢
  • 2021-09-13
  • 2021-06-08
  • 2021-09-07
  • 2022-12-23
  • 2021-11-25
  • 2021-06-02
相关资源
相似解决方案