PHP Archives - Ian Carnaghan

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...

Sep 2 · 29 sec read >

Comparison Operators

PHP comparison operators allows you to compare two values with each other. Below is a table of all the...

Mar 22 · 37 sec read >

How to subtract a number of days from todays date using PHP date function

$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...

Mar 22 · 30 sec read >

How to print the contents of an array using PHP

//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 ( ...

Mar 22 · 19 sec read >

How to get the Nameservers of a domain using PHP

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...

Mar 22 · 19 sec read >

What is the purpose of the & Ampersand in front of PHP Variables

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...

Mar 22 · 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...

Mar 22 · 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...

Mar 22 · 28 sec read >

How to solve error: ‘PHP Warning: DOMDocument::createElement(): unterminated entity reference’ when creating a new element using the DOMDocument object model

DOMDocument = Represents an entire HTML or XML document; serves as the root of the document tree.  (PHP 5) DOMDocument::createElement()  = Create new...

Mar 22 · 13 sec read >