Syntax problem echo ">" (only PHP)

Hi Everyone,

I am facing quite a few weird syntax problems on the host i am using.

I just want to print <drive>

so i am using

**1. echo “<drive>”;

  1. echo “<” . “drive” . “>”;

  2. $synt="<";
    $synta=">";
    echo $synt . “drive” . $synta;

  3. $synt="&lt;";
    $synta="&gt;";
    echo $synt . “drive” . $synta;

  4. $synt="<";
    $synta=">";
    echo $synt . “drive”;**

The first 4 don’t give me any output. The 5th gives me
<drive

So what is the problem in printing “>”. I have used single quotes for all as well. And on my host newline works with
echo “<br />”;
instead of normal "
";
So why is this difference.
Please have a look at it.

Thanks.

hrm … that would be one weird hosting issue if in fact it is your host. #5 doesn’t print the closing > cause you’re not echoing $synta. But outside of that your echo is in fact echoing, it’s probably just being parsed by HTML as an HTML tag, much like if you did <div> it wouldn’t show up as “<div>” on the actual page HTML rather it’d show in the source code as <div>. What you need to do is:


echo htmlentities("<drive>");

as for the “normal” way of doing a newline, <br/> is the HTML parsed version of
, if you do
the new line will show up in view source since it’s not being parsed, but HTML doesn’t parse
it parses <br/>

WOW! Thanks!!!

That did it. But i still have to code a whole XML in PHP on this host. So this is just a highly imp first step for me.

Is this something related to PHP version, or i mean is there any way to know or find some source that would tell me the correct syntax for this type of host?

"#5 doesn’t print the closing > cause you’re not echoing $synta."
I did this in Point No.3 but when i use “$synta” or “>” anywhere then it doesn’t show any previous echos.

Anyway i hope the rest would work with “htmlentities” way too.

Many Many Thanks for your help!!

if you setup your headers to be xml, the first ones would work as well since they wouldn’t be interpreted as html.

Just remember to view source :wink:

[QUOTE=sekasi;2353096]if you setup your headers to be xml, the first ones would work as well since they wouldn’t be interpreted as html.
[/QUOTE]

How do i set up headers as XML. Do you mean this:

header(‘Content-type: application/xml’);

i included it in the beginning of my file but doesn’t work. :frowning:

[QUOTE=simplistik;2353086]hrm … that would be one weird hosting issue if in fact it is your host. #5 doesn’t print the closing > cause you’re not echoing $synta. But outside of that your echo is in fact echoing, it’s probably just being parsed by HTML as an HTML tag, much like if you did <div> it wouldn’t show up as “<div>” on the actual page HTML rather it’d show in the source code as <div>. What you need to do is:


echo htmlentities("<drive>");

as for the “normal” way of doing a newline, <br/> is the HTML parsed version of
, if you do
the new line will show up in view source since it’s not being parsed, but HTML doesn’t parse
it parses <br/>[/QUOTE]

I added code like
echo htmlentities("<?xml version="" . “1.0"” . “encoding=”" . “ISO-8859-1”?" . “>”);
echo “<br />”;

and likewise for the rest of XML as well. When i run the PHP directly in my browser, it shows me the correct structure.
But when i read it through external application(in this case Flash) then it interprets the above code as :
<?xml version="1.0"encoding=“ISO-8859-1”?>,<br />

What do i do…:crying:

echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
echo '<br />';

[QUOTE=Templarian;2353233]

echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
echo '<br />';

[/QUOTE]

I tried that with no luck.

Actually now i removed everything and using straight things like

echo ("<dri_info>");

When i run it directly in the browser it doesn’t show me anything but surprisingly flash interprets it correctly. It is working but still the question is why doesn’t the browser show it. Or when the browser shows with
**echo htmlentities("<drive>"); **

then why doesn’t Flash reads it correctly.

Anyway, Thanks everybody for your help. It is all Highly appreciated. :fab:

I got a fix:

print('<?xml version="1.0" encoding="ISO-8859-1"?>');
print('<br />');

Okay I would highly recommend you call your hosting provider and get this fixed rather than just “work around it”.

[QUOTE=Templarian;2353300]I got a fix:

print('<?xml version="1.0" encoding="ISO-8859-1"?>');
print('<br />');

Okay I would highly recommend you call your hosting provider and get this fixed rather than just “work around it”.[/QUOTE]

I should have contacted them in the beginning of my project. Everything is working good now indirectly. Now i am just left with updating my database through PHP and i hope i don’t get any syntax problem now.

I still have to try the above code.

Thanks a lot. :slight_smile:

Not to be harsh but, it’s not the host at all, it’s a matter of you not understanding the scope of PHP and Flash how they work, and even how they work in tandem.

Of course Flash won’t process anything converted by htmlentities. What you asked was how to make HTML physically show brackets instead of processing the node/element. Then what you asked is how to make Flash process the node/element that was converted to be physically displayed by HTML. When you write HTML and you do:


<p>Foo</p>

your output is not

Foo

it’s just Foo. And just like if you did

echo "foo";

in a php file, your output would be foo, but if you did it in HTML it would be echo “foo”;

So when you do <drive> it tries to process it in the same manner as it does <p> by escaping the brackets and turning them into “HTML entities” < now becomes &lgt; and > becomes &rgt; which is used for HTML display purposes only. Where as Flash will accept them literally.

Yes you are correct. I understand your point on htmlentities thing.

But still this thing is happening on this Host only

One month back i did similar kind of XML-PHP thing on some other host. ANd that time i used

echo "<XML Tag>"
or
echo “<?xml version=“1.0” encoding=“ISO-8859-1”?>”;

and it worked perfectly there. So it must be this host is not accepting the same syntax correctly that worked on the other.Or maybe there is some configuration thing. And atleast when i used Escape characters then it should have worked correctly.

And one more thing i would like to add :
Very recently i did some Flash-PHP image uploading thing. And, if i am remember correctly i uploaded in on 4 different host,surprisingly it worked only on 2 of them . Then just wrote 4-5 lines of HTML for uploading with minor change in PHP(for HTML) and it worked everywhere.

But different host have different security or configuration settings with my experience so far.
So it must be something with the host. It might be just simple setting… :slight_smile:

Anyway i hope to get things right now on this host. Now most of the things are working.

Thanks all for your help again.