Page 1 of 1

could u explain why for these fun lines?

Posted: Thu Jul 28, 2005 6:42 am
by php12342005
first all, do not simply give me a link, i did read many docs from google but i can not find answer.
explain first, then links - thanks.

followings are code in a php file but out of <?php?> tag.

===============================================
<?php $var0="hello, boys"; ?>

<form>
<input type="text" value=<?php print("'$var0'"); ?> style="width:200;">
<br>
<input type="text" value=<?php print("$var0"); ?> style="width:200;">
<br>
<input type="text" value=<?php print($var0); ?> style="width:200;">
</form>

<?php print("'$var0'"); ?>
<br>
<?php print("$var0"); ?>
<br>
<?php print($var0); ?>
<br>
===============================================
output:
-------------- first 3 lines (in inputs) are:
hello, boys
hello,
hello,
-------------- last 3 lines (not in inputs) are:
'hello, boys'
hello, boys
hello, boys

if you compare a line (in input) with respective line (not in input), you see they are different.

what does first 3 lines mean?
(last 3 lines are easy to be understood)

why?

by the way: is print() the same as echo()?

Posted: Thu Jul 28, 2005 6:47 am
by timvw
It means that you are generating invalid (X)HTML.
by the way: is print() the same as echo()?
If you read the manual carefully, not the way you did now, you should know the answer.

Posted: Thu Jul 28, 2005 8:06 am
by Ree
you have invalid input's.

Posted: Thu Jul 28, 2005 8:48 am
by Chris Corbyn
php12342005 are you doing it on purpose??? Use

Code: Select all

tags please... I'm not doing it for you this time.. every time we ask you you do not seem to be taking it on board - in fact, you argued against it the last time   

68 posts - still not listening.

Posted: Thu Jul 28, 2005 7:46 pm
by harrisonad
The HTML you generated is

Code: Select all

&amp;lt;form&amp;gt; 
&amp;lt;input type=&quote;text&quote; value='hello, boys' style=&quote;width:200;&quote;&amp;gt;&amp;lt;br&amp;gt; 
&amp;lt;input type=&quote;text&quote; value=hello, boys style=&quote;width:200;&quote;&amp;gt;&amp;lt;br&amp;gt; 
&amp;lt;input type=&quote;text&quote; value=hello, boys style=&quote;width:200;&quote;&amp;gt; 
&amp;lt;/form&amp;gt;
The first line is the standard way to write tag attribute values using either " or '. The last two are not. Whenever you deprive the value from quotes, HTML will take the first word, in your case, 'hello,' as its valid value. And the rest of the sentence will be ignored.
Now if you are complaining about the quotes not showing up in the textbox, its normal. But if you want so, it must be generated as this...

Code: Select all

value=&quote;'hello, boys'&quote;
in php ...

Code: Select all

value=<?php print("\"'hello, boys'\""); ?>