Research and Development work on PHP, MYSQ,JQuery,Angular Js,React Native,Laravel,Wordpress,Magento,Joomla
Showing posts with label Core PHP. Show all posts
Showing posts with label Core PHP. Show all posts
Friday, June 7, 2013
Thursday, June 6, 2013
server-side GZIP Script in php (define in .htaccess file)
#Gzip <ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript </ifmodule> #End Gzip
Tuesday, June 4, 2013
PHP Email Validation
<?php
$email_a = 'joe@example.coddddm';
$email_b = 'bogus';
if (filter_var($email_a, FILTER_VALIDATE_EMAIL)) {
echo "This (email_a) email address is considered valid.";
}
if (filter_var($email_b, FILTER_VALIDATE_EMAIL)) {
echo "This (email_b) email address is considered valid.";
}
?>
$email_a = 'joe@example.coddddm';
$email_b = 'bogus';
if (filter_var($email_a, FILTER_VALIDATE_EMAIL)) {
echo "This (email_a) email address is considered valid.";
}
if (filter_var($email_b, FILTER_VALIDATE_EMAIL)) {
echo "This (email_b) email address is considered valid.";
}
?>
Friday, May 31, 2013
Jquery form submit and image upload through ajax
<a href="http://docs.google.com/file/d/0B4nDLq9K61UvaFhmQk15TEhwVkU/edit?usp=drive_web" target="_blank" class="fileitem-linked" rel="noreferrer">jquery-image-upload.zip</a>
CSS Hack for Google Chrome,Safari,ie7,ie8
@media screen and (-webkit-min-device-pixel-ratio:0)
{
.classname{ background:#ccc; } /*It will works on Google chrome and safari */
}
IE7
.classname{*background:#ccc; } /*It will works on IE7 */
.classname{background:#ccc \9; } /*It will works on IE8 */
{
.classname{ background:#ccc; } /*It will works on Google chrome and safari */
}
IE7
.classname{*background:#ccc; } /*It will works on IE7 */
.classname{background:#ccc \9; } /*It will works on IE8 */
Thursday, May 23, 2013
Tuesday, May 21, 2013
Monday, April 29, 2013
PHP Script to create cache
1). Create Folder Name "cache";
2).
ob_start();
$strUrl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if(file_exists("cache/".basename($strUrl)))
{
require_once("cache/".basename($strUrl));
}
else
{
echo "This is home page content......................";
}
$fp = fopen("cache/".basename($strUrl),"w");
fwrite($fp, ob_get_contents());
fclose($fp);
ob_end_flush();
2).
ob_start();
$strUrl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if(file_exists("cache/".basename($strUrl)))
{
require_once("cache/".basename($strUrl));
}
else
{
echo "This is home page content......................";
}
$fp = fopen("cache/".basename($strUrl),"w");
fwrite($fp, ob_get_contents());
fclose($fp);
ob_end_flush();
Check whether site is down or good using php
function VisitSite($url)
{
//$agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,$url );
//curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch,CURLOPT_VERBOSE,false);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$page=curl_exec($ch);
//echo curl_error($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode >= 200 && $httpcode < 300){
return true;
}
else {
return false;
}
}
if(VisitSite('http://www.google.co.in'))
{
echo "Website looks Good<br />";
}else
{
echo "Website looks Down<br />";
}
Compress & decrease the page loading time using HTACCESS
Subscribe to:
Posts (Atom)