Hi, I work with a ubuntu system and php 5.2.1. The next code doesn't convert special characters and html codes to entities! <html> <head> <title>Text including html</title> </head> <body> <?php echo phpinfo(); $str= <<<TEXT Einstürzende Neubauten and Marya's & <br>Mother and again "test". TEXT; $code=htmlentities($str, ENT_QUOTES); $code1=htmlspecialchars($str); echo $code,"<br>",$code1; ?> </body> </html> Code (markup): The output of the code is: Could you tell me why my code doesn't work? Thanks,
wow, that's interesting.. I'm still working on my Fedora 7 with the internet now.. haha... but try to use print instead of echo, and also, try to use <br />
Just for referance.. print() is just an alias of echo() Also care to explain how you fixed it? Might as well in case someone else has the same issue and stumbles upon this thread.
i think he just had to change the charset encoding of his html page to UTF-8 or UTF-16. And print is not really an alias of echo: echo is a php language construct while print is a php function. To outcome is exactly the same, but it's a different type
actually, both print() and echo() are language constructs. the only significant difference is that print() has the ability to span across multiple lines without concatenating unlike echo().