base64 encode using javascript


We can encode any string to a encoded data (using base-64 encoding) string.
The btoa() method of window object used to to a encoded data (using base-64 encoding) string.
Example :

window.btoa(‘Hello World !!!’);

Output : SGVsbG8gV29ybGQgISEh

Use Facebook to Comment on this Post

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…

iowait


How iowait impacts System performance System or any server’s performance heavily depends on IOPS. And if MySql is running on the System, it requires disk of high IOPS. Lots of select queries running simultaneously cause high iowait if disk dont have high IOPS. High iowait means cpu is waiting for I/O access. That increase the…

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'; }

selecting data from mysql db using regular expression


A regular expression is a powerful way of specifying a pattern for a complex search. Below is a simple example. select email from foo where email REGEXP ‘foo.com$’; In the above example, It will list all the email which ends with foo.com. “$” sign is used to denote the end of the string.

default modifier in smarty


“default” used to set a default value for a variable. If the variable is unset or an empty string, then the default would be display. This modifier accepts one parameter which is the default value to show. {$foo|default:’Default text’}

Count number of characters in a string in smarty


We can count number of characters in a string through the smarty. Smarty provide a modifier called “count_characters”. {$str|count_characters} Above statement will display the number of characters in the string excluding the white-spaces. {$str|count_characters:true} Above statement will display the number of characters in the string including the white-spaces.