usertest
usertest

Reputation: 27648

PHP stop closing tag being automatically added

When I add the string below to an array in PHP and output it,

$spineArray[$i]="<itemref idref='part-$i' linear='yes'/>";

It looks like this when outputted. Why is the closing tag automatically added and can I stop it? Thanks.

<itemref idref='part-$i' linear='yes'> </itemref>

Upvotes: 1

Views: 2380

Answers (5)

Benjamin Cremer
Benjamin Cremer

Reputation: 4822

I think you used the firefox "view selected source". It shows the interpreted/corrected/parsed state of the html. If you use "view source" (CONTROL + u) you will see the raw markup.

Try for yourself:

<p>lorem<br />ipsum</p>

In "view selected source <br /> transform to <br>":

<p>lorem<br>ipsum</p>

In "view source <br /> stays <br />":

<p>lorem<br />ipsum</p>

Upvotes: 1

DrColossos
DrColossos

Reputation: 12998

Are you using FireBug to look at the HTML? Firebugs adds missing tags on it's own. Make sure that you look at the HTML with the browser's "View Source" feature

edit: Your replay to kander makes it obvious. If you look at the code as described above, I'm sure you won't see the tag added.

Upvotes: 4

Brad
Brad

Reputation: 163612

Based on your paste, I assume you are viewing this in some sort of XML viewer. It's possible for the XML to be displayed this way.

Upvotes: 0

Karel Petranek
Karel Petranek

Reputation: 15164

What do you use to process and output it? There must be some HTML/XML processing tool in the way because PHP itself doesn't do this.

The answer is to remove the HTML/XML processing or keep a copy of the string in another variable and output that one.

Upvotes: 0

kander
kander

Reputation: 4306

I can assure you that PHP doesn't do this - at least, not by itself. Where are you looking when you see the output you describe?

Chances are that whatever you're using to view the output in is not showing the raw output, but the result of it parsing the XML you give it, but without some more information, I'm afraid your question cannot be answered.

Upvotes: 16

Related Questions