In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what will happen to the output of dynamic HTML in PHP". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what's wrong with the output of dynamic HTML in PHP"!
1-
When you try to add two (or more) spaces between hello and world
You use:
Echo "helloworld!"
The output you get is still a space, or you add a space at the beginning of the line
Your spaces will also be ignored.
2-
To make matters worse, when outputting user input, intentional or unintentional user input will
Make your output a mess and even cause trouble for other users.
For example:
If there is more than one line in the user's input, then you simply
Echo$in_txt
The user's line break will be ignored.
What problems will be encountered in the output of dynamic HTML in PHP
3-
Again, in the above example, in most cases we do not want the user to enter html
Code, because you don't know what the user will type.
Users can even write a piece of code to make all the users of your site crash.
Of course you don't want that, but if you simply
Echo$in_txt
It's impossible to avoid.
Solution:
For 1, you can use ereg_replace ("{2}", "$nbsp;", $in_txt)
Two spaces together will become escape characters for two spaces ($nbsp).
For 2dint nl2br ($in_txt) is the best choice, so all line breaks are changed to
"
"that's it.
For 3, the html code entered by the user is safely displayed, and there are also special functions in php.
Htmlspecialchars ($in_txt) is fine.
In addition, if $in_txt is proposed from the mysql database, then when it was previously inserted
Be sure to use addslashes () and, accordingly, stripslashes () when you take it out.
Summary:
If $in_txt is the text entered by the user, you can generally output it like this:
Echoereg_replace ("{2}", "", nl2br (htmlspecialchars (stripslashes ($in_txt)
At this point, I believe you have a deeper understanding of "what will happen to the output of dynamic HTML in PHP". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.