Strange <<<XML syntax in Canada Post REST web service

Hi, I am using PHP with Canada Post’s REST web service to get postage rates. Their PHP example code shows composing an XM request string using a strange <<<XML … XML; syntax that I have not seen before and can find no documentation about anywhere on the web. Does anyone know how this works and where the <<<XML … XML; syntax comes from? Thanks. Their code is as follows :

$xmlRequest =
<<<XML
<?xml version="1.0" encoding="UTF-8"?>


{$mailedBy}

     <parcel-characteristics>
        <weight>{$shipCarton->WeightKg}</weight>
     </parcel-characteristics>

     <origin-postal-code>{$originPostalCode}</origin-postal-code>
     <destination>
        <domestic>
           <postal-code>
              {$shipToAddress->PostalCode}
           </postal-code>
        </domestic>
     </destination>
  </mailing-scenario>

XML;

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

OK, thanks.

David

Np :slight_smile: Just come back if you have other questions :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service