Pages with tag PHP

Correct character encoding with DOMDocument implementing a Wordpress content filter Using DOMDocument in a Wordpress content filter lets you correctly manipulate the content as HTML. It might be that Wordpress filters are commonly using regular expressions or text search/replace functions. While that can be fast and powerful, correctly changing HTML elements requires an HTML-oriented API. The specifics of HTML elements are such that regular expressions and text search/replace functions just don't cut it due to the many pitfalls from highly specific details of HTML. With DOMDocument you simply load the HTML into the library, then you use DOM functions to manipulate the HTML, then you serialize the DOM to HTML text, and voila powerful HTML manipulations easily performed. Unfortunately that method comes with its own pitfalls you must be careful of.
Installing Composer on a Dreamhost VPS, or perhaps other VPS's

Modern PHP software development has been modernized by Composer. My exposure to Composer is because the Drupal team adopted the Symfony framework, which in turn is based on Composer. Installing Drupal any longer seemingly requires to first install Composer. Which isn't installed by default on Dreamhost VPS's, but it's not too hard to get it going.

Setup Google Recaptcha v2 in PHP scripts

Recaptcha has been around a long time, fighting the good fight against spammers. One of my sites has been using Recaptcha for years, long enough to require updating to new API implementations a couple times. Google has updated to Recaptcha v2 and soon v3, and somehow my site stopped enforcing Recaptcha's with the subsequent Spammer intrusions. Fixing the implementation proved to be difficult, especially as the available tutorials missed some details.