PHP Archive

How to Test Email Spam Score

You can test the spam score of your emails/newsletters before sending them out. What is Email Spam Score? A spam score is a score given to emails by SpamAssassin or similar software on the incoming mail server. The email spam score is determined by a range of checks, validations and algorithms to give an email

WordPress: Get Role by User ID

You may want to get the role of a WordPress user by ID or even the role of the current user. First off, if you’re doing this for the current user, you can use the global $user_ID variable as the current user ID. Here is a quick function you can use to get the role

PHP $_COOKIE variable empty

The PHP $_COOKIE variable is a reserved variable and Array in PHP which contains cookies in the browser stored by PHP, Javascript and other languages. If for any reason you are using PHP setcookie() or Javascript document.cookie to set cookies and the PHP $_COOKIE variable remains empty it might actually be a server configuration that

PHP: Enable GD image library

Many features that you see on the web require that the GD library be enabled on your PHP server. You may need the GD library if you are attempting to display CAPTCHA graphics somewhere on your site. In a default PHP installation, the GD library should already be enabled. The following How To explains how

PHP: Copy image from remote server to local server

You might want to copy an image (or any other file) with PHP from a remote location to your local server and store it in a specific location. You can use the PHP file_get_contents() function to achieve this. Here is a code sample: $remoteimage = ""; $localimage = "/home/domain/httpdocs/path/to/my/image.jpg"; if ($content = file_get_contents($remoteimage)) { if


I’ve pretty much tried all the PDF libraries out there for saving HTML to PDF appropriately and correctly using PHP and came to a conclusion (continue reading). The one that worked the fastest and most efficiently was the HTML to PDF class on PHP Classes but eventually this EasySW remote HTML to PDF service in

PHP: URL inside Regex

Using special, regular expression characters in regular expressions require you to escape them in the regular expression pattern. I had an issue with dynamically getting an array of URLs from HREF attribute from links using PHP preg_match_all and then wanted to replace this array of URLs dynamically in a loop again with their links

DomPDF images not working

Are you having problems with images not displaying in DomPDF generated PDFs? The probable reason is because you’re linking your images in HTML with a path from the script or with an absolute URL like this: OR The solution is to change the image SRC to the absolute path

Turn off error reporting on your production site

On a production site, you would most likely want to hide all possible PHP errors, warnings and notices from your users for both usability, presentational and security purposes.

Install WordPress via Command Line

I wrote a useful article/tutorial over at BloggingRocket which guides you through the process of installing WordPress with Shell Access. Please feel free to check it out and comment.