Rich-text formatting in PHP: HTML, Markdown, rich-text editors like TinyMCE and doing it securely

Опубликовано: 07 Март 2025
на канале: Dave Hollingworth
11,584
186

PHP for Beginners course: ➤ https://davehollingworth.net/phpy
PHP MVC course: ► https://davehollingworth.net/phpmvcy
CodeIgniter 4 course: ► https://davehollingworth.net/codeigni...

In an HTML form, a textarea element is used to collect a sizeable amount of text. You can enter more text than a regular text input, but it's still just plain text. In this video we'll look at how to allow the user of a form to add formatting to the content. We'll also learn how to do it securely to avoid code injection. We'll look at using HTML directly, using a plain-text markup language like Markdown, and using a rich-text editor in the browser like TinyMCE.

Resources:
https://daringfireball.net/projects/m...
https://packagist.org/packages/erusev...
https://www.tiny.cloud/
https://www.php.net/manual/en/functio...
http://htmlpurifier.org/

Code shown in the video:
https://gist.github.com/daveh/b93ca07...

00:00 Intro
01:13 Allowing HTML
02:38 Markdown
05:52 Rich-text editors
10:28 Using strip_tags
12:46 Using HTMLPurifier
16:29 Summary