Skip to content

Instantly share code, notes, and snippets.

View PBC43's full-sized avatar

Philippe PBC43

View GitHub Profile
@xeoncross
xeoncross / domdocument_encoding.php
Last active July 8, 2023 14:46
Fix HTML encoding errors with PHP DOMDocument
<?php
// Ignore errors
libxml_use_internal_errors(true) AND libxml_clear_errors();
// http://stackoverflow.com/q/10237238/99923
// http://stackoverflow.com/q/12034235/99923
// http://stackoverflow.com/q/8218230/99923
// original input (unknown encoding)
@oliworx
oliworx / etag.php
Last active July 27, 2022 12:25
Browser caching with Etag and PHP: this saves bandwith and speeds up the loading for the visitor, very useful for mobile pages
ob_start(); // collect all outputs in a buffer
/*
put the normal PHP-Code here
if the resulting html code ($sContent) is the same, and so the md5 hash is the same,
it will not be sent so the client once more
because the client already has this html page in the cache, identified by the md5 hash Etag
*/
$sContent = ob_get_contents(); // collect all outputs in a variable
ob_clean();