PHP string cannot contain HTML tag

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mindvoyager
Forum Newbie
Posts: 1
Joined: Wed Apr 09, 2008 1:08 am

PHP string cannot contain HTML tag

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: PHP string cannot contain HTML tag

Post 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>
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply