Detect Mobile device through javascript


A pretty simple solution is to check for mobile device is the screen width. Almost all mobile devices have a max screen width of 480px.
We can get the screen width using below statement:

var screen_width = window.screen.availWidth;

The only exceptions are tablet pc’s like the ipad….

Advertisements

cookie and subdomains


A cookie can be set either for a specific domain or a domain and its subdomain. Cookie for a specific domain: When you set a cookie from a web server in php using setcookie() function then this function accepts some parameters. Some parameters are required and some are optional. In those parameters there is one…

APC Cache


As APC is used for speeding up php sites it by caching php. But many times we face caching problem. We need to clear php cache. It is easy to clear cache from web url but many of us dont know that apc cache can not be cleared from CLI mode. For command line ,…

PHP Best Practise


Always use PHP standard tags i.e.  <?php ?> .  To ensure the future version support, Please use standard tags for PHP. Always follow a consistent naming standards. Always use Indent and white spaces in codes. It helps to read and understand the code. Always turn on the full error reporting for development. It will show…

Output buffering in php


Output buffering is used by PHP to improve performance and to perform a few tricks. Without output buffering (the default), your HTML is sent to the browser in pieces as PHP processes through your script. With output buffering, your HTML is stored in a variable and sent to the browser as one piece at the…

Ternary Operators


This operator takes three arguments – a condition, a result for true, and a result for false. It is a shortcut of doing if statements. Here’s an example: $result = ($a < 16) ? 'true' : 'false'; if ($a < 16) { $result = 'true'; } else { $result = 'false'; }