Jump to content

special html char does't work ?


han2754

Recommended Posts

hi all

I just try to run the code below ( I used wamp)

the php version is 5.2.6

I think there something wrong with my configuration setting,but i am not sure

I hope help to find it

 

thank you

--------------------------------

<?php

$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);

echo $new; // <a href=&#039;test&#039;>Test</a>

?>

 

--------------------------------

the result displayed on screen is below

--------------------------------

<a href='test'>Test</a>

--------------------------------

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/125264-special-html-char-doest-work/
Share on other sites

And what would you expect the result to be?

 

here is may be more clearer example

 

the code is below

-------------------------

<?php # testslashn php

 

#

 

  print "Creating a table...\n";

  print "Inserting some rows to the table...\n";

  print "Query some rows from the table...\n";

 

?>

---------------------------

I hope the 3 sentences print in three lines,but it print in only one line .

Yes I can replace \n with <br> ,but why the book tell me that I can line feed by using \n ,if it doesn't really work ?

 

thanks

hanafi tan

It works.

Thing is, you watch the output from php script that is parsed by web browser. And for web browsers /n means nothing.

If you check source of what is displayed, you will see that you have this in three lines.

If you save the page to the text file and open it in the notepad, you'll see three lines.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.