Users through the browser submitted markdown format of browsing, PHP will be in the original markdown format saved to the database ... What does PHP do with the user input in this process? In particular, the user input HTML code, how the original code display.
Add: The database is the original MD text, my question is to store to the database, the user input of the MD How to deal with?
Reply content:
Users through the browser submitted markdown format of browsing, PHP will be in the original markdown format saved to the database ... What does PHP do with the user input in this process? In particular, the user input HTML code, how the original code display.
Add: The database is the original MD text, my question is to store to the database, the user input of the MD How to deal with?
This one, you have to pay attention to two points:
1. Data validation before storage, keep in mind that all user input content is not trustworthy. Remember!!!
2. Visually you want to display this content on the page, you can't show it directly ... What you have to show to the user is the MD converted to HTML format in order to be friendly! Oh, yes.
In view of the above two points: can go to a website: https://packagist.org/
Search markdown
: You will find a lot of wheels ~ Of course, you have to use composer
~ What? You said you didn't use this? Why isn't?
With a markdown parser, the top of the page shows the markdown format of the edge display has been resolved
Save two when you save a database
Remove the saved markdown when you need to update
Output the saved HTML directly when you want to see it