PHP display all errors and warnings

When writing a program in PHP it is a good idea to activate all the errors and warnings that often occur during development. Many hosts have the display of errors disabled, so you can ‘go…

Convert URLs and HTML Code to PDF with PHP

Our API is a free solution for converting web pages and HTML documents to PDF with PHP. Here is a simple example: <?php $data = array(“apikey” => “YOUR_API_KEY”, “html” => “<p>My first pdf with <b>.Maui…

How to parse an xml sitemap using PHP and Curl

<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ‘https://www.example.com/sitemap.xml’); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch,CURLOPT_USERAGENT,’Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36′); $resp = curl_exec ($ch); $xml = new SimpleXMLElement($resp); foreach ($xml->url…

Prevent sql injection with php

Here is a simple function to prevent Sql Injection with PHP. Just recall it and check both GET and POST parameters <?php function checkInjection() { $badchars = array("DROP", "SELECT", "UPDATE", "DELETE", "INSERT", "TRUNCATE", "UNION ALL",…

Remove script tags from string with PHP

Remove script tags (or other types of tags) from a string in PHP is really easy, here’s how: <?php $html = <<<HTML <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="https://cdn.dotmaui.com/dotmaui/css/dark.css" /> <script> alert('1') </script> <script…

Add PHP code into .html files

To process files with a .htm or .html file extension as PHP files you must add the following line to the file.htaccess (if this file does not exist, create it on the site ROOT). AddType…

Small PHP class to write log files

Here is a small class in PHP to write log files. If the file name is not specified, it will be assigned by the script. <?php class Log { private $PATH; function __construct($file_name = null)…