PHP

Like in php, this function returns the current Unix timestamp with microseconds.

Usage
var d = php.microtime();
var d = php.microtime(true); 

You can assign this to a variable like you see above and use it later on.



Note:

Returns the string "microsec sec" by default, where sec is the number of seconds since the Unix Epoch (0:00:00 January 1, 1970 GMT), and microsec is the microseconds part. If the get_as_float parameter is set to TRUE, it returns a float representing the current time in seconds since the Unix epoch accurate to the nearest microsecond



Like in php, this function generates a unique ID based on the microtime (current time in microseconds)

Usage
var d = php.uniqid();
var d = php.uniqid("foo");

You can assign this to a variable like you see above and use it later on.





The str_replace() function finds and replaces some characters with some other characters in a string.

Usage
php.str_replace(find,replace,string)


Example 1
php.str_replace("world","Mark","Hello world!") //output --> Hello Mark!

Example 2
Arr1 = ['Code','With']

Arr2 = ['Awesome','Functions']

String = "This is Code With JS Library."

php.str_replace(Arr1,Arr2,String) //output --> This is Awesome Functions JS Library.

Example 3
var strDIV = '<div>{Code}</div>';
strDIV += '<div class="{ReplaceClassName}"> </div>';

Arr1 = ['{Code}','{ReplaceClassName}'];
Arr2 = ['Awesome Functions', 'AwesomeFunctionClass'];

var Data = php.str_replace(Arr1,Arr2,strDIV) 

//Out put to body or whatever element id you want to
$('body').html(Data);

$('#MyID').html(Data);

$('.MyClassName').html(Data);

//Will output this
<div>Awesome Functions</div>
<div class="AwesomeFunctionClass"></div>




This will Decode your php base64_encode() string

Usage
//Syntax 
php.Decode(StringVal)

php.Decode("Y29kZXdpdGhtYXJr")
 
//--->Out put will
codewithmark

 

Ideal usage

Let's suppose you want to add an extra layer of security to your user's password 

In your php, encode your password and save it in a cookie: setcookie("user_password",base64_encode ("password")  );

On your client side javascript, you can decode the password like this:

1) Read the cookie: var passwd = c.Get("user_password");

2) php.Decode(passwd)