PHP

How to embed images using PHPMailer

Use the AddEmbeddedImage method provided by the PHPMailer class.  eg. $mail->AddEmbeddedImage(‘test.gif’,’testImage’,’test.gif’); Parameters for AddEmbeddedImage($path, $cid, $name = ”, $encoding = ‘base64’, $type = ‘application/octet-stream’) $path = Path to the attachment $cid = Content ID...
Ian Carnaghan
29 sec read

Comparison Operators

PHP comparison operators allows you to compare two values with each other. Below is a table of all the different comparison operators that are...
Ian Carnaghan
37 sec read

How to subtract a number of days from todays…

$var = ‘2007-08-15’; $var_subtracted_date = date(‘Y-m-d’, strtotime(‘-2 days’, strtotime($var))); Explanation of PHP functions: 1) FUNCTION date DESCRIPTION string date ( string $format  ) PARAMETERS USED IN THIS EXAMPLE Y = A full numeric representation...
Ian Carnaghan
30 sec read

How to print the contents of an array using…

//Array example $arr = array(‘one’,’two’,’three’,’four’); Use the print_r function. Example: print_r($arr); The example above will print out the following: Array ( => one => two...
Ian Carnaghan
19 sec read

How to get the Nameservers of a domain using…

Use the  dns_get_record function with type DNS_NS Example: //Add this piece of code to your PHP will $result = dns_get_record(‘yourdomain.com‘,DNS_NS); Execute the script //An array will be returned...
Ian Carnaghan
19 sec read

What is the purpose of the & Ampersand in…

What this does it creates a reference to the original variable and thus does not copy the value of the original variable. $original_var = 500; &$ref_var = $original_var; //This will print...
Ian Carnaghan
21 sec read

How to remove duplicate values in a PHP array

Use the array_unique function array_unique (PHP 4 >= 4.0.1, PHP 5) array_unique (Takes an input array and returns a new array without duplicate values) array_unique (array $array  ) Example: CODE:...
Ian Carnaghan
20 sec read

How to embed images using PHPMailer

Use the AddEmbeddedImage method provided by the PHPMailer class. eg. $mail->AddEmbeddedImage(‘test.gif’,’testImage’,’test.gif’); Parameters for AddEmbeddedImage($path, $cid, $name = ”, $encoding = ‘base64’, $type = ‘application/octet-stream’) $path = Path to the attachment $cid = Content ID...
Ian Carnaghan
28 sec read

How to solve error: ‘PHP Warning: DOMDocument::createElement(): unterminated entity…

DOMDocument = Represents an entire HTML or XML document; serves as the root of the document tree.  (PHP 5) DOMDocument::createElement()  = Create new element node. (PHP 5) Now...
Ian Carnaghan
13 sec read