xHTML 1.0 STRICT code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="/css/style.css" rel="stylesheet" type="text/css" />
<script src="/js/script.js" type="text/javascript"></script>
</head>
<body>
...
</body>
</html>
Standaard CSS:
* {
margin:0;
padding:0;
}
img {
border:0;
}
jQuery link:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript"></script>
jQuery, uitgaande links openen in nieuwe tabblad:
var pathname = window.location.pathname;
$("a[href^='http://'], a[href^='http://www.'], a[href^='www.'] ,a[rel='external']").not("a[href^='http://www.'pathname], a[href^='http://'pathname], a[href^='www.'pathname]").attr('target','_blank');
Display PHP errors:
error_reporting(E_ALL);
ini_set('display_errors', '1');
UTF-8 header:
header('content-type: text/html; charset: utf-8');
IP Block:
<?php if($_SERVER["REMOTE_ADDR"]=="38.107.179.216"): ?>
<?php endif; ?>
Input field zonder auto-complete:
<input type="text" name="name" autocomplete="off" />
Mobile meta tags:
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/css/medium.css" media="only screen and (max-width: 1024px)">
Mail headers:
$headers = "From: info@example.com\r\n";
$headers .= "Message-ID: <" . md5(uniqid(time())) . "@example.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Date: ".date("D, d M Y H:i:s") . " UT\r\n";
$headers .= "Reply-To: info@example.com\r\n";
$headers .= "Return-Path: info@example.com\r\n";
$headers .= "X-Priority: 3\r\nX-MSMail-Priority: Normal\r\n";
$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
$headers .= "X-MimeOLE: Produced By Company Name\r\n";
mail($to, $subject, $message, $headers);
Insert query:
$query = "INSERT INTO table (field1, field2) VALUES (:value1, :value2)";
$result = $mysql->prepare($query);
$result->bindParam(':value1', $value1);
$result->bindParam(':value2', $value2);
$result->execute();
Update query:
$query = "UPDATE table SET field1=:value1, field2=:value2 where id=:id";
$result = $mysql->prepare($query);
$paramArray = array(':id'=>$id, ':value1'=>$value1, ':field2'=>$value2);
$result->execute($paramArray);
Delete query:
$query = "DELETE FROM table WHERE field1=:value1 AND field2=:value2";
$result = $mysql->prepare($query);
$result->bindParam(':value1', $value1);
$result->bindParam(':value2', $value2);
$result->execute();
Gehele site inladen op ander domein:
//url opgeven van de site welke moet worden opgehaald
$siteUrl = "http://voorbeeld.nl".$_SERVER["REQUEST_URI"];
$mainUrl = explode("/",$siteUrl);
$mainUrl = $mainUrl[0]."/".$mainUrl[1]."/".$mainUrl[2];
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $siteUrl);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$site_contents = curl_exec($ch);
curl_close($ch);
echo
//links naar javascript e.d. worden vervangen
str_replace('src="/','src="'.$mainUrl.'/',
//alle href's naar /css worden vervangen (de map waar je css in zit)
str_replace('href="/css','href="'.$mainUrl.'/css',
//opgehaalde informatie wordt op de pagina gezet
$site_contents
));