开发者

PHP: Splitting long query string across multiple lines

开发者 https://www.devze.com 2023-01-16 10:25 出处:网络
I\'ve got a long string which I want to split accross multiple lines so it\'s easier to read. but I\'m not sure what the syntax is

I've got a long string which I want to split accross multiple lines so it's easier to read. but I'm not sure what the syntax is

$xml = array('sXML' =>"<queryxml><entity>Ticket</entity><query><field>Status<expression op=\"$condition1\">$complete</expression></field><condition operator=\"AND\"><field>AccountID<expression op=\"equals\">$userid</expression></field></condition><condition operator=\"AND\"><condition><field>QueueID<expression op=\"NotEqual\">$routine<开发者_如何学C/expression></field></condition><condition operator=\"OR\"><field>QueueID<expression op=\"NotEqual\">$recurring</expression></field></condition><condition operator=\"OR\"><field>QueueID<expression op=\"NotEqual\">$clientmanagement</expression></field></condition></condition></query></queryxml>");

Can someone help me out please?


just split it into multiple strings and concatenate them, like this:

$xml = array('sXML' => "lorem" .
 "ipsum" .
 "dolor");

or use heredoc:

$sXML = <<<XML
your text
goes here
XML;

$xml = array('sXML' => $sXML);


If it doesn't matter if linebreaks are added, you can simply write:

<?php
$xml = array('sXML' => "<abc>
<def>Asdfg</def>
</abc>";
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消