Posts

Showing posts from December, 2012

php format date string short month

As you can see in our last example there are tons of different formats that can be used in the date feature. Below is a summary of the variable used in date, and what each does. Remember they ARE CaSe sEnsItIVe: DAYS   d - day of the month 2 digits (01-31)   j - day of the month (1-31)   D - 3 letter day (Mon - Sun)   l - full name of day (Monday - Sunday)   N - 1=Monday, 2=Tuesday, etc (1-7)   S - suffix for date (st, nd, rd)   w - 0=Sunday, 1=Monday (0-6)   z - day of the year (1=365) WEEK   W - week of the year (1-52) MONTH   F - Full name of month (January - December) m - 2 digit month number (01-12)   n - month number (1-12)   M - 3 letter month (Jan - Dec)   t - Days in the month (28-31) YEAR L - leap year (0 no, 1 yes) o - ISO-8601 year number (Ex. 1979, 2006) Y - four digit year (Ex. 1979, 2006) y - two digit year (Ex. 79, 06) TIME a - am or pm A - AM or PM B - Swatch Internet time (000 - 999) g - 12 hour (1-12) G - 24 hour c (0-23) h - 2 digi

Attempting to understand handling regular expressions with php

Regular Expression, commonly known as RegEx is considered to be one of the most complex concepts. However, this is not really true. Unless you have worked with regular expressions before, when you look at a regular expression containing a sequence of special characters like /, $, ^, \, ?, *, etc., in combination with alphanumeric characters, you might think it a mess. RegEx is a kind of language and if you have learnt its symbols and understood their meaning, you would find it as the most useful tool in hand to solve many complex problems related to text searches. Just consider how you would make a search for files on your computer. You most likely use the ? and * characters to help find the files you're looking for. The ? character matches a single character in a file name, while the * matches zero or more characters. A pattern such as 'file?.txt' would find the following files: file1.txt filer.txt files.txt Using the * character inst

Regular expression handler quicker learn in php

Regex quick reference [abc]     A single character: a, b or c [^abc]     Any single character but a, b, or c [a-z]     Any single character in the range a-z [a-zA-Z]     Any single character in the range a-z or A-Z ^     Start of line $     End of line \A     Start of string \z     End of string .     Any single character \s     Any whitespace character \S     Any non-whitespace character \d     Any digit \D     Any non-digit \w     Any word character (letter, number, underscore) \W     Any non-word character \b     Any word boundary character (...)     Capture everything enclosed (a|b)     a or b a?     Zero or one of a a*     Zero or more of a a+     One or more of a a{3}     Exactly 3 of a a{3,}     3 or more of a a{3,6}     Between 3 and 6 of a PCRE Patterns preg_match_all() - Perform a global regular expression match preg_replace() - Perform a regular expression search and replace preg_split() - Split string by a regular expression preg_last_error() - Returns the error cod

php email reader and notification though header parameters

down vote accepted For the reading confirmations: You have to add the X-Confirm-Reading-To header. X - Confirm - Reading - To : <address> For delivery confirmations: You have to add the Disposition-Notification-To header.

Authorize.net ARB class Automated recurring billing class

<?php class AuthnetARBException extends Exception {} class WP_Invoice_AuthnetARB { private $login; private $transkey; private $params = array(); private $sucess = false; private $error = true; var $xml; var $response; private $resultCode; private $code; private $text; private $subscrId; public function __construct() { $this->url = stripslashes(get_option("wp_invoice_recurring_gateway_url")); $this->login = stripslashes(get_option("wp_invoice_gateway_username")); $this->transkey = stripslashes(get_option("wp_invoice_gateway_tran_key")); } private function process($retries = 3) { $count = 0; while ($count < $retries) { $ch = curl_init(); //required for GoDaddy if(get_option('wp_invoice_using_godaddy') == 'yes') { curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt ($ch, CUR

php image upload class file

<?php     class Uploader     {         private $destinationPath;         private $errorMessage;         private $extensions;         private $allowAll;         private $maxSize;         private $uploadName;         private $seqnence;         public $name='Uploader';         public $useTable    =false;         function setDir($path){             $this->destinationPath  =   $path;             $this->allowAll =   false;         }         function allowAllFormats(){             $this->allowAll =   true;         }         function setMaxSize($sizeMB){             $this->maxSize  =   $sizeMB * (1024*1024);         }         function setExtensions($options){             $this->extensions   =   $options;         }         function setSameFileName(){             $this->sameFileName =   true;             $this->sameName =   true;         }         function getExtension($string){             $ext    =   "";             try{                     $parts  =  

array pagination using php class

<?php   class pagination   {     var $page = 1; // Current Page     var $perPage = 10; // Items on each page, defaulted to 10     var $showFirstAndLast = false; // if you would like the first and last page options.         function generate($array, $perPage = 10)     {       // Assign the items per page variable       if (!empty($perPage))         $this->perPage = $perPage;             // Assign the page variable       if (!empty($_GET['page'])) {         $this->page = $_GET['page']; // using the get method       } else {         $this->page = 1; // if we don't have a page number then assume we are on the first page       }             // Take the length of the array       $this->length = count($array);             // Get the number of pages       $this->pages = ceil($this->length / $this->perPage);             // Calculate the starting point       $this->start  = ceil(($this->page - 1) * $this->perPage);             // Return the pa

Steps for installation of fonts on Windows 2008 Server and Tomcat Application Sever.

Image
Windows 2008 Server 1.        Look for the folder named “Fonts” in your windows folder. Most probable it will be “ C:\Windows\Fonts\ ”. Fonts folder can also be find using by running the command “ %windir%/fonts ”. 2.        Copy the required font in the above mention “Fonts” folder. Tomcat Application Sever 1.        Copy the required fonts on tomcat’s JRE inside {JRE_HOME}/lib/fonts/. Step for finding Tomcat JRE Path 1.        Go to the apache home directory (Apache Software Foundation\Tomcat 6.0\logs\service-install.log). it’s can also be find search this file service-install.log in c drive. 2.        Then open the file and check jvm path just like (bin\Tomcat5.exe" --Jvm " C:\Program Files\Java\jre7\ bin\client\jvm.dll"). this is your java home directory “ C:\Program Files\Java\jre7\ ” 3.        Find path like C:\Program Files\Java\jre7\lib\fonts 4.        Copy the required font in the above mention “Fonts” folder. 5.        Then restart tomcat server. Another way