Sunday, July 26, 2015

Screen Sizes for PSD, standard psd size for website

Higher screen resolutions ultimately make everything look smaller. enter image description here enter image description here
A very small percentage of Internet users are still using older resolutions like the once popular 800×600.
Sites using a 720px width appear very small on high resolution screens, and don’t leave room for a sidebar. Now most websites are staying somewhere around 960px wide. Some sites are even catering to the latest technology with much wider sites.
enter image description here
Although it is important to consider the newest devices, I believe the optimal website width is still 960px wide. This width caters to the majority of devices and makes your site fit nicely in both 1024px and 1366px wide screens.
960 is divisible by 2, 3, 4, 5, 6, 8, 10, 12, and 15. It is a dream for making a perfect grid site. This leads to the popular resource called the “960 grid system“.

Friday, May 22, 2015

How to Send a Confirmation Email with a File Attachment

<?php
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "Reply-To: ".$replyto."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $message."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$uid."--";
// Messages for testing only, nobody will see them unless this script URL is visited manually
if (mail($mailto, $subject, "", $header)) {
echo "Message sent!";
} else {
echo "ERROR sending message.";
}
}
// Only accept POSTs from authenticated source
if ($_POST['HandshakeKey'] != 'secret-handshake-key') {
echo "<h1>You are not who you say you are, mister man.</h1>";
die();
}
// EDIT FROM HERE DOWN TO
// CUSTOMIZE EMAIL
// File to attach
$my_file = "whitepaper.doc";
$my_path = ''; // $_SERVER['DOCUMENT_ROOT']."/your_path_here/";
// Who email is FROM
$my_name = "Your Name (or) Your Business";
$my_mail = "youremail@yourbusiness.com";
$my_replyto = "youremail@yourbusiness.com";
// Whe email is going TO
$to_email = $_POST['Field103']; // Comes from Wufoo WebHook
// Subject line of email
$my_subject = "Your file has arrived!";
// Content of email message (Text only)
$requester = $_POST['Field101']; // Comes from Wufoo WebHook
$message = "Hey $requester,
Your custom email message
goes here";
// Call function to send email
mail_attachment($my_file, $my_path, $to_email, $my_mail, $my_name, $my_replyto, $my_subject, $message);
?>

Monday, March 16, 2015

Understanding the ‘self’ keyword in PHP

In PHP, you use the self keyword to access static properties and methods.
The problem is that you can replace $this->method() withself::method() anywhere, regardless if method() is declared static or not. So which one should you use?
Consider this code:
class ParentClass {
 function test() {
  self::who(); // will output 'parent'
  $this->who(); // will output 'child'
 }

 function who() {
  echo 'parent';
 }
}

class ChildClass extends ParentClass {
 function who() {
  echo 'child';
 }
}

$obj = new ChildClass();
$obj->test();
In this example, self::who() will always output ‘parent’, while $this->who() will depend on what class the object has.
Now we can see that self refers to the class in which it is called, while$this refers to the class of the current object.
So, you should use self only when $this is not available, or when you don’t want to allow descendant classes to overwrite the current method.

Thursday, March 12, 2015

Thursday, January 29, 2015

Get content between two special character from a string in php

<?php
$string='[countrycontent countryname="GB"] london [/countrycontent]

[countrycontent countryname="IN"] INDIA [/countrycontent] [countrycontent countryname="IN"] INDIA [/countrycontent]';
preg_match_all('/\](.*?)\[/',$string, $matches);

// array [1] is the stripped matches... array[0] would reurn with the []'s :)
$matches1 = $matches[1];
$contentA=array();
// cycle through the matches and add them to the searched for string
foreach ($matches1 as $match1){
 
   $contentA[]=$match1;
}



preg_match_all('/\"(.*?)\"/',$string, $matches);

// array [1] is the stripped matches... array[0] would reurn with the []'s :)
$matches2 = $matches[1];
 $countryA=array();
// cycle through the matches and add them to the searched for string
foreach ($matches2 as $match2){

   $countryA[]=$match2;
}

$result = array_combine($countryA, $contentA);

foreach($result as $key=>$v)
{
if($key=="GB")
{
echo $v;
}

}




?>

Popular Posts