simpleXML - What does <<<XML mean?

Hello all,

I’ve seen this and I’m wondering what <<<XML means? What is it’s propose?


$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" 

I looked into google but couldn’t find a way to query this. <<< :s

Thanks in advance,
Márcio

A good example would be a string which requires single quotes, double quotes and variables.

Sure, sprintf etc could do it, but not without escaping - and escaping is something I dislike :stuck_out_tongue:

You see, I’d wrap a template object round that… :confused:

Overkill, possibly - but I don’t think so.

I’m a little OCD ( :stuck_out_tongue: ), and just find its use very strange and ugly. I’ve yet to see, what I consider, justified use of this feature.

Don’t get me wrong, I’m sure there are, but I haven’t seen any yet.

I’m not sure about what stream wrapper means, even with the php manual.
But it seems that if we use it, we need to establish the connection on a specific way. Well… on this case, only TCP/IP socket connections are allowed by the server.

Well… but we are getting off-topic. I will post specific questions when I start creating this EPP Protocol php Class. (this sounds really fancy :cool:, shame that I know so little about it). :lol:

K. Regards,
Márcio

It sucks!?

Can you please elaborate, I’m intrigued.

I’m also intrigued. I don’t use it often, but it does come in handy, eg code generation.

I’d argue if you had a lot of "'s to deal with, i.e non-code, what are they doing in your code in the first place…

You’re most welcome. :wink:

Have you thought of implementing a stream wrapper to take the ‘legwork’ out of it?

Good points. :slight_smile:

So can I go like:


$xml = simplexml_load_file("test.xml");
//and... here we goo...

Well, I’m not yet sure what best fits here.

The task that I have in hands is more or less like this:
Receive a frame from the server:
Remove the initial 4 bytes (that contain the length of the frame),
Read the XML that is returned.

Send a frame to the server:
Construct (or open) a XML file;
Adding the fields on specific nodes based on some rules.
Save or end the construction of the XML file.
Add the 4 bytes with the length and send the frame.

The frame, is the sum of:
the initial 4 bytes (containing the frame length, including this 4 bytes) + XML syntax.

And it’s according to this scenario that I’m not sure about what direction should I take.

(:

Márcio

Thanks. :slight_smile: Despite the strange and long sintax it seems to be nice for using when we have a lot of " and ‘’ to deal with.

Thanks again,
Márcio

It’s the HEREDOC syntax, it sucks. IMO. :eye:

I like HereDoc syntax for large sections of multiline output; Sometimes I use the C-style printf() function, othertimes HereDoc. I never come OUT of PHP unless I’m in a template file.