Archive

May 2015

Browsing

Lollipop updates for Moto E 1st generation – Features and reviews.

Every one more exited with the new android version of  LOLLIPOP.  Some of them have updated lollipop via OTA (Over-The-Air) their mobile and enjoying its features. For MOTO serious, Moto x,  Moto G (1st and 2nd generation), Moto E 2nd Generation have lollipop update directly to your phone.

Still didn’t Check, Just go with steps,

Settings -> About Phone -> System updates

Lollipop updates for Moto E 1st generation

It show New system software available Click “yes, I’m in” and follow the steps finally update Complete, enjoy(Use WI-FI connection)

Lollipop updates for Moto E 1st generation

Lollipop updates for Moto E.

For Moto E(1st generation) they didn’t release lollipop version to the phone directly (Except some first level users). But don’t worry you can manually update the lollipop to your mobile. The problem is have  to root you phone. There is lot of risk while update manually. Whatever, Still wanna update manually. Let me explain the steps. Before that the size of moto E Lollipop is 341.7Mb. Atleast 500 MB of storage space is required to Install the Moto E Lollipop , so free up the internal storage by transferring your data, apps to sd card

 Steps :

  1. Download the file from here http://bit.ly/1B6HdYq (Mediafire) or here http://bit.ly/1ElrjqJ (Devhost)
  2. Download Motorola Update Services apk from here http://bit.ly/1z9Lox0. Install it on your device.
  3. Put the zip file to root of internal memory. (Root means simply internal or external memory.)
    Make sure that you have at least 500 mbs free in your internal memory as we said before.
  4. shutdown your mobile and Reboot your phone.
  5. Now goto Settings -> About Phone -> System updates,  see “New system software available”. Click on “Yes I’m in”.
  6. Download begins.  Once the download is complete, swipe down the notification bar and click on Install system update->Install now.
  7. Its Rebooting your mobile automatically you have to wait 10-20 mins
  8. While your mobile will start booting, don’t panic just let it be, its new software so took some more time be patience.
  9. Finally its updated,  ‘Say Cheers yourself’ and enjoy the Lollipop updates.

At last step delete you zip file, Its no need there after.

Lollipop updates for Moto E 1st generation Enjoy the Coding.

 

How to Handle Cookie in Php and set Cookie time in browser

What Is Cookie?

Cookie is a small file embedded with server to the user’s browser. Its mainly used to Get or Identify the user details. Every time the same computer requesting a page with a browser, it will also send the cookie.
By locally we said, Its stored the pages and details in you browser History. you can check once the link in history. Until you cleared the history the webpage details are stored in you browser, you browser details are stored in the server with the help of cookie function.

Advantage of stored cookie is, If we browsing very large website or server in your browser its take large time to load for first time. But Second time its doesn’t take much time (send request to the server and get full website), it can easily access the website with the help of browser history which can previously stored using cookie.

How to Handle Cookie in Php and set Cookie time in browser

Using PHP you can create cookie function and set cookie and destroy cookie.

1. Create Cookies
A cookie is created with the setcookie() function.
Syntax

setcookie(name, value, expire, path, domain, secure, httponly);

parameters
name (* required)   –   user name
value (* required)   –   user value
expire (optional)     –   can set expire time
path (optional)        –  url path
domain (optional)  –   server domain name

all are optionals

Example Code

<?php
$name = "developerdesks";                 // assign name to the cookie
$value = "Php";                            // assign value to the cookie
setcookie($name,$value,time() + (86400 * 30));         // assign cookie expire time 86400 = 1 day
?>
<html>
<body>
<?php
if(!isset($_COOKIE[$name])) {                           // check cookie 
echo "Cookie is not set set to the browser";
} else {
echo "Cookie '" . $name . "' is set!<br>";              //print cookie name
echo "Value is: " . $_COOKIE[$name];                    //print cookie value
}
?>
</body>
</html>

 

Explaination

Set cookie name, value and expire time to the page using setcookie() function
The cookie “Developerdesks” and “php” is stored in you browser as cookie

Real Time Checking
1. Run this code in your browser for first time the output is
“Cookie is not set set to the browser”
2.Refresh the same page again the output is
“Cookie ‘developerdesks’ is set!
Value is: Php”

Cookie “developerdesks” and “php” are stored in you browser history.

3. Delete the histor us CTRL+H -> clear browsing data -> Check “Cookies and other sites and plug-in data” and clear browsing data with the past hour.  now run the same page the output is

How to Handle Cookie in Php and set Cookie time in browser

“Cookie is not set set to the browser”

Because the cookie is deleted or expired. once you cleared history the cookie is deleted or expired.

If you not cleared the history its automatically cleared once the cookie set time is expired.

HINT : The setcookie() function must appear BEFORE the HTML tag or top of the page.

2. Modify the cookie.
We just create another user name and another setcookie function to modify the cookie values.

<?php
$name = "developerdesks";                                 // assign name to the cookie
$value = "Php";                                           // assign value to the cookie
setcookie($name,$value,time() + (86400 * 30));            // assign cookie expire time 86400 = 1 day
$name = "user";                                           // updated cookie name
$value = "Alex Porter";                                   // updated cookie value
setcookie($name, $value, time() + (86400 * 30), "/");
setcookie("user", "Alex Porter", time() - 3600);
?>
<html>
<body>
<?php
if(!isset($_COOKIE[$name])) {                               // check cookie 
echo "Cookie is not set set to the browser";
} else {
echo "Cookie '" . $name . "' is set!<br>";                  //print cookie name
echo "Value is: " . $_COOKIE[$name];                        //print cookie value
}
?>
</body>
</html>

 

Output :

Cookie ‘user’ is set!       // Last Updated Cookie
Value is: Raja

3. Delete the Cookie
Just set expire time to delete the cookie

<?php
setcookie("user", "", time() - 3600);          // set the expiration date to one hour ago
echo "Cookie 'user' is deleted.";
?>

 

After one hour you reload the page the cookie is unset or delete

Output
Cookie ‘user’ is deleted.

How to Handle session variables in Php

How to Handle session variables in Php

Session is nothing but way to store a details or information (using variables) in multiple pages. Its Not like as Cookie.
The difference is details are not stored in the computer browser as like as cookie.

What is PHP Session? – Simple and clear Explanation

When You open a page in the browser. It have a login page. you logged in. browse some pages, update some changes and do all thing and closed it. From Your computer, know this who you are, what you do, where is it. But from Internet or server don’t know about all things. because the HTTP address doesn’t maintain state.

Here session works. It stored all login details or any information using session variable. It will carry the details to all the pages, links, update contents and changes until you unset or destroy the session. which means until you log-out or close the browser.

Syntax – how to start a Session
session_start();   // Session syntax

Session Variables is globally declared as $_SESSION  // variable syntax

Example

<?php
session_start();  // Start the session sysntax

$_SESSION["developer"] = "php "; // Session variable declared
$_SESSION["desks"] = "Html";   // Session variable declared

echo "We are learning " . $_SESSION["developer"] . ".<br>";      // Print session variable values
echo "We are also learning " . $_SESSION["desks"] . ".";    // Print session variable values

?>

Output :

We are learning php
We are also learning Hmtl

Here You can call the session variable where you want.

Print all session in single output
We can also Print all the Session in single array function
Syntax

<?php
session_start(); // Start the session sysntax
$_SESSION["developer"] = "php "; // Session variable declared
$_SESSION["desks"] = "Html"; // Session variable declared
print_r($_SESSION);
?>

 output

Array ( [developer] => php [desks] => Html )

Modify the session variable
We can also modify the session variable where u want and when you want. It print last modified value only

<?php
session_start();  // Start the session sysntax
$_SESSION["developer"] = "php "; // Session variable declared
$_SESSION["desks"] = "Html";   // Session variable declared
$_SESSION["developer"] = "WELCOME";   // Simple modify the session variable
echo "We are learning " . $_SESSION["developer"] . ".<br>";      // Print session variable values
echo "We are also learning " . $_SESSION["desks"] . ".";    // Print session variable values
?>

 Output

We are learning WELCOME // Session variable print the last modified values
We are also learning Hmtl

Destroy or Unset the session variable
Want to remove all global session variables and destroy the session, we can use session_unset() and session_destroy():
Syntax:

<?php
session_start(); // Start the session sysntax
$_SESSION["developer"] = "php "; // Session variable declared
$_SESSION["desks"] = "Html"; // Session variable declared
$_SESSION["developer"] = "welcome";
session_unset();  // Session unset used to remove all the variables in the session
session_destroy();  // Delete or End the session
echo "We are learning " . $_SESSION["developer"] . ".<br>"; // Print session variable values
echo "We are also learning " . $_SESSION["desks"] . "."; // Print session variable values
?>

If you run this code in your browser

Output
Notice: Undefined index: developer in you URL
We are learning .

Notice: Undefined index: desks in you URL
We are also learning .

Because variables are unset and destroyed.

Want to see the real time session variables functions work in multiple pages Click Here

Login page using session,  user details with out stored in database

Like this session some related functions also in php they are like cookie() and local storage()

COOKIE

LOCAL STORAGE

How to search the key values in the array – array_search

If we have a very large array values in Indexed or Associative array, we have to search or filter the particular array value or key.

Array_Search function is used to find the value.

This  function used to  search an array for a value and returns the key.

<?php
$search =array('a'=>'php','b'=>'css','c'=>'html,'d'=>'dssd','e'=>'eeee',f=>'fdfd','g'=>'dsfsd',....);
echo array_search('css',$search);
?>

 

In the Given example, we have to find whether  “CSS” Find or not in the array. It prints the key of the value.

Output

b   // output

Explaination

array_search is used to search the array value(‘css’) and returns the value’s key(‘b’);

2. In_array()

In_array is simillar to the array_search

In_array Functions is used to find the value in the array list

using this function you can find the value is present or not in array queue.

syntax: In_array();

you can search anything value or key using IN_ARRAY();

for example

have to find “Developerdesks” in the given array

<?php

$var = array(‘raj’,’sekar’,’developer’,’desks’,'php','html','css','developerdesks','designer');

if(in_array('developerdesks', $var, ))
{
echo "found Developerdesks";
}
else
{
echo "not found";

}

?>

 

You can see explanation in this url

 

Function to find particular value or key in the array for php – In_array functions

Function to find particular value or key in the array for php – In_array

In_array Functions is used to find the value in the array list

using this function you can find the value is present or not in array queue.

syntax: In_array();

for example

have to find “Developerdesks” in the given array

<?php

$var = array(‘raj’,’sekar’,’developer’,’desks’,'php','html','css','developerdesks','designer');

if(in_array('developerdesks', $var, ))
{
echo "found Developerdesks";
}
else
{
echo "not found";

}

?>

Explanation:

If you want find a particular key or value in the very long array for any action..

<?php

$var = array(‘raj'=>'1233','sekar'=>'434','developer'=>'asd','desks'=>'ded','developerdesks'=>'free','designer'=>'dsa');

?>

here ‘raj’ is ‘key’ and  ‘1233’ is ‘value’

you can search anything value or key using IN_ARRAY();

Similar to In_array();

2. array_search() 

If we have a very large array values in Indexed or Associative array, we have to search or filter the particular array value or key.

Array_Search function is used to find the value.

This  function used to  search an array for a value and returns the key.

You can see Explanation Here

How can we print array with in array using for-each loop – Three dimensional array

A multidimensional array is an array containing one or more arrays.

Three-Dimensional array

For three dimensional array u have to use two for loop condition
find 0 indexed array value and then 0 indexed array value

<?php

$developedesks = array(
"Skills" => array
(
"php" => 80,
"css" => 85,
"html" => 80
),
"design" => array
(
"photoshop" => 70,
"flash" => 75,
"indesign" => 72
),
"framework" => array
(
"wordpress" => 85,
"drupal" => 75,
"joomla" => 70
)
);

$count = count($developedesks);
echo "$count<br/>";
foreach($developedesks  as $develop => $desks)
{

foreach($desks as $key =>$value)
{
echo "$develop &nbsp; $key &nbsp; $value<br/>";
}

}

?>

Explain

First foreach consider skill as $develop and php =>80 as $desks

Second For each consider $key as php and $ value as 80

so the $develop –> indexed as skill, $key–> indexed as php and $value indexed as 80

simple foreach concept worked

Output

Skills  php  80
Skills  css    85
Skills  html   80
design  photoshop 70
design  flash    75
design  indesign   72
framework wordpress 85
framework drupal   75
framework joomla   70

 

Similar like three dimensional array

Multidimensional Array concept in Php

A multidimensional array is an array containing one or more arrays.

Its is solution for to know how to handle a array with in array
Example
1.Two-dimensional array
2.Three-dimensional array

Here You can see Exaplaination

How We used Multidimensional Array concept in Php?

Multidimensional Array concept in Php

A multidimensional array is an array containing one or more arrays.

Its is solution for to know how to handle a array with in array
Example
1.Two-dimensional array
2.Three-dimensional array

1.Two-dimensional array

<?php

$develop= array(
array("developer",php,html),
array("desks",php5,html5),
array("raja",css,ajax),
array("sekar",jquery,drupal)
);

$count= count($develop);
echo "$count";

 for ($row = 0; $row < $carss; $row++) {
echo "<p><b>Level $row</b></p>";
echo "<ul>"; 
for ($col = 0; $col < 3; $col++) {
echo "<li>".$cars[$row][$col]."</li>";
}
echo "</ul>";
}

?>

Output

Indexed Level 0
developer
php
html

Indexed Level 1
desks
php5
html5

Indexed Level 2
raja
css
ajax

Indexed Level 3
sekar
jquery
drupal

Explanation:

First For loop consider all array values inside the array  –> array(“developer”,php,html) as 0 indexed

Second For loop consider inside values –> Developer as 0 indexed

For two dimensional array u have to use two for loop condition

find 0 indexed array value and then 0 indexed array value

simple example

<?php

echo $develop[0][0].": langauge 1: ".$develop[0][1].", language 2: ".$develop[0][2].".";
echo $develop[1][0].": langauge 1: ".$develop[1][1].", langauge 2: ".$develop[1][2].".";
echo $develop[2][0].": langauge 1: ".$develop[2][1].", langauge 2: ".$develop[2][2].".";
echo $develop[3][0].": langauge 1: ".$develop[3][1].", langauge 2: ".$develop[3][2].".";

?>

Example For Three-Dimensional array

How to print array values in php using mysql – associative array

Associative array is array that use named keys that you assign to them.

example

<?php

$var2 = array('raj'='123','sekar'=>'213','developer'=>'545','desks'=>'345');

echo $var2['raj']; // output is 123
echo $var2['sekar']; // output is 213
echo $var2['developer']; // output is 545
echo $var2['desks']; // output is 345

?>

named key ‘raj’ has vlaue ‘123’;

IF the named key is unknown and unlimited the use foreach

<?php

$var3 = array('raj'='123','sekar'='213','developer'='545','desks'='345','php'='34','html'='54654','css'='123'); 

foreach($var3 as $X=>$value)
{
echo $X .$value;
}

?>

output

raj 123
sekar 213
developer
545
desks 345
php 34
html 54654
css 123

Similar like Associative array

Multidimensional Array concept in Php

A multidimensional array is an array containing one or more arrays.

Its is solution for to know how to handle a array with in array
Example
1.Two-dimensional array
2.Three-dimensional array

Here You can see Exaplaination