Sunday, 29 July 2012

Cookie in CakePHP

Write Cookie:
$this->Cookie->write('countryName', 'India', false, 0); Argument Description sequence: cookie name, value, encrypted or not if set false means cookie will store as plain text.
Read Cookie:
echo $this->Cookie->read('countryName');
Output: India

Saturday, 28 July 2012

strstr() Function

Finds first occurance of any string from a given string.
strstr() function is a case sensitive function to use case insensitive stristr() is used.
e.g
$emailId = 'test@mydomain.com';
$domainName = strstr($emailId, '@');
echo $domainName; // outputp will be: mydomain.com
$firstPart = strstr($email, '@', true); // PHP 5.3 and above
echo $firstPart; // outputp will be: test
?>

Friday, 27 July 2012

sprintf() function

function sprintf() returns a formatted string, according to the formatting string format.
$numOfStudent = 50;
$class = 'Class';
$format = 'There are %d Students in the %s';
echo sprintf($format, $numOfStudent, $class);
// output will be: There are 50 Students in the Class
?>

Thursday, 26 July 2012

strrpos() function

Finds position of the last occurance from a string.
e.g
$str = 'abcd';
$chkStr = 'b';
echo strpos($str,$chkStr); // output will be: 1
?>

Tuesday, 24 July 2012

strstr() Function

Finds first occurance of any string from a given string.
strstr() function is a case sensitive function to use case insensitive stristr() is used.
e.g
$emailId = 'test@mydomain.com';
$domainName = strstr($emailId, '@');
echo $domainName; // outputp will be: mydomain.com
$firstPart = strstr($email, '@', true); // PHP 5.3 and above
echo $firstPart; // outputp will be: test
?>

Monday, 23 July 2012

CSS Opacity property

Transparency property of CSS is called opacity.
img
{
opacity:0.5;
filter:alpha(opacity=50); /* Used in IE8 or below version of IE */
}
Opacity range is 0.0 - 1.0, more lower opacity values means more transparent element.
property opacity is used in Firefox, Opera, IE9, Chrome and Safari for transparency. But IE8 or lower version uses filter:alpha(opacity=x). Here value x ranges from 0-100. Lower x value means more transparent element.

Friday, 20 July 2012


tabindex property

tabindex attribute is used to set tab order for element.

<input name="first" tabindex="2" type="text" />
<input name="second" tabindex="3" type="text" />
<input name="third" tabindex="1" type="text" />
Above input box will highlight in sequence : third,second,first when we press tab key.