-1
$xmlSend = <<<TEXT
                    <?xml version="1.0" encoding="UTF-8"?>
                        <VMCAMEXM>
                            <business>
                                <id_company>{$idCompany}</id_company>
                                <id_branch>{$idBranch}</id_branch>
                                <country>{$Country}</country>
                                <user>{$User}</user>
                                <pwd>{$pwd}</pwd>
                            </business>
                            <transacction>
                                <merchant>{$Merchant}</merchant>
                                <reference>50000</reference>
                                <tp_operation>13</tp_operation>
                                <creditcard>
                                    <crypto>{$Crypto}</crypto>
                                    <type>V/MC</type>
                                    <name>{$name}</name>
                                    <number>{$number}</number>
                                    <expmonth>{$expmonth}</expmonth>
                                    <expyear>{$expyear}</expyear>
                                    <cvv-csc>{$cvv}</cvv-csc>
                                </creditcard>
                                <amount>{$cantidad}</amount>
                                <currency>{$Currency}</currency>
                                <usrtransacction>1</usrtransacction>
                            </transacction>
                        </VMCAMEXM>
TEXT;

echo "<pre>";
print_r(htmlspecialchars($xmlSend));
echo "</pre>";

            //$url = $tUrl;         
            $vars = "&xml=" . $rc4->limpiaVariable(urlencode($xmlSend)); 
            $header[] = "Content-type: application/x-www-form-urlencoded";
            $ch = curl_init();
            $postfields = "info_asj3=1".$vars;

             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
             curl_setopt($ch, CURLOPT_URL,$Url);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_TIMEOUT, 250);
             curl_setopt($ch, CURLOPT_POST, true);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
             curl_setopt($ch, CURLOPT_HTTPHEADER, $header);          

             $data = curl_exec($ch);
                if (curl_errno($ch)) {
                   $data = curl_error($ch);          
                } else {
                   curl_close($ch);
                }

I am working with a new company that is using this to connect to an xml feed. But using this beginning <<<TEXT is messing up all the code below it. I do not get any errors, the code works, but all my php code below is in black and honestly just is not easy to manage. If I take it out the xml feed does not function properly. Can someone tell me why this is working and what is a better way to accomplish this? I have searched everywhere and can find nothing on the topic. PLEASE HELP!

Thank you to anyone in advance for taking the time to answer!

luv2code
  • 1,216
  • 6
  • 22
  • 42
  • See also [Reference - What does this symbol mean in PHP?](http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) – mario Sep 27 '12 at 01:58

2 Answers2

2

This is Heredoc syntax of string.

Using Heredoc for string has the benefit for multi-line strings and can avoid the quoting issues.

xdazz
  • 158,678
  • 38
  • 247
  • 274
0

This is a HEREDOC string, if you are running into problems with it, it's likely due to the indentation of the closing sequence:

TEXT; //<-- must be in the 0th column, of the text file.

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

Lucas Green
  • 3,951
  • 22
  • 27