This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$to = '[email protected]'; | |
$subject = $name . ' is requesting a free delivery'; | |
$body = '<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<h1>Title</h1> | |
<table> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ellipsis($string, $max_length) { | |
return (strlen($string) > $max_length) ? substr($string,0,strrpos(substr($string, 0, $max_length), ' '))."…" : $string; | |
} | |
print ellipsis("All your base are belong to us", 20); | |
# All your base are… |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// usage: place your start date into $start variable i.e. $start = '2008' | |
$start = ''; | |
echo( ($start < date('Y') ? 'Copyright © ' . $start . ' - ' . date('Y') . ', all rights reserved' : 'Copyright © ' . $start . ', all rights reserved') ); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ip_address = $_SERVER['REMOTE_ADDR']; | |
$blocked = array('72.214.3.245_off', '208.113.135.66', '67.130.131.194', '70.179.6.61'); | |
if (in_array($ip_address, $blocked)){ | |
echo "blocked"; | |
}else{ | |
echo "not blocked"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function generateCsv($data, $delimiter = ',', $enclosure = '"') { | |
$handle = fopen('php://temp', 'r+'); | |
foreach ($data as $line) { | |
fputcsv($handle, $line, $delimiter, $enclosure); | |
} | |
rewind($handle); | |
while (!feof($handle)) { | |
$contents .= fread($handle, 8192); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// simple phone number | |
$phone_number_as_integer = preg_replace("/[^0-9]/", "", $phone); | |
if( !preg_match("/^()?[0-9]{3}[0-9]{3}[0-9]{4}$/i", $phone_number_as_integer) ) | |
{ | |
$phone_error = 'Please enter a valid phone number.'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'http://example.com'; | |
$validation = filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED); | |
if ( $validation ) | |
{ | |
$output = 'proper URL'; | |
} | |
else | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Email Address Validation | |
Check the variable $email is a valid email address. | |
Usage: | |
print validate_email("[email protected]"); | |
Or: | |
$email = "[email protected]"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CardValidation { | |
public $valid = false; | |
public $valid_cc; | |
public $valid_cc_type_pair; | |
public $valid_ccv_type_pair; | |
public $error; | |
public function validate($cc, $type = false, $ccv = false) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text-shadow(@color: #000, @size: 1px){ | |
text-shadow: @size @size 1px @color; | |
}/* Eric Meyer's Reset Reloaded *//* http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ */html, body, div, span, applet, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,a, abbr, acronym, address, big, cite, code,del, dfn, em, font, img, ins, kbd, q, s, samp,small, strike, strong, sub, sup, tt, var,b, u, i, center,dl, dt, dd, ol, ul, li,fieldset, form, label, legend,table, caption, tbody, tfoot, thead, tr, th, td {margin: 0;padding: 0;border: 0;outline: 0;font-size: 100%;vertical-align: baseline;background: transparent;}body {line-height: 1;}ol, ul {list-style: none;}blockquote, q {quotes: none;}/* remember to define focus styles! */:focus {outline: 0;}/* remember to highlight inserts somehow! */ins {text-decoration: none;}del {text-decoration: line-through;}/* tables still need 'cellspacing="0"' in the markup */table {border-collapse: collapse;border-spacing: 0;} | |
.clearfix:after { | |
visibility: hidd |