Page 1 of 1

PHP string cannot contain HTML tag

Posted: Wed Apr 09, 2008 1:29 am
by mindvoyager
Hi all
I am trying to append an HTML tag to a PHP string, and nothing happens. Example follows:

<?PHP
$pitems = "begin";
$pitems .= "<next>";

printf("output=%s",$pitems);
?>

The output is:
output=begin

It works all right with "<next~", which then disappears if I str_replace "~" with "> ". I am wondering whether this is a PHP bug, or some kind of configuration option that I don't know about, or just me being thick. I am using PHP version 4.4.7

I have searched the net till I'm sick of it. Can anyone throw any light on this?

David

Re: PHP string cannot contain HTML tag

Posted: Wed Apr 09, 2008 1:58 am
by s.dot
It is probably being appended to the string, you just can't see it because your browser is treating it as an HTML tag. If you view the source of the file, you'll probably see it.

I just tried it on command line and got the desired output. So it is working.

Code: Select all

C:\Users\scott>php -r "$a = 'begin'; $a .= '<next>'; printf('output=%s', $a);"
output=begin<next>