Tuesday, November 25, 2014

md5 function in php

<?php
$string="123";
echo md5($string);
?>

htmlentities function in php

<!DOCTYPE html>
<html>
<body>

<?php
$str = "<© W3Sçh°°¦§>";
echo htmlentities($str);
?>

<p>Converting characters into entities are often used to prevent browsers from using it as an HTML element. This can be especially useful to prevent code from running when users have access to display input on your homepage.</p>

</body>
</html>

Sunday, November 23, 2014

You can altime live cricket

Saturday, November 8, 2014

How to setting time in php

<?php
//format 12 hours time jone
echo date("h: i:s");
//formate 24 hours jone
echo date("H: i:s");
//increase time form present time
$timeset=strtotime("+50 hours");
echo date("H:i:s",$timeset);
?>

How to upper string from lower

<?php
$string_ano="joynob";
$string_to_upper=strtoupper("$string_ano");
echo $string_to_upper;
?>

How to lower string from upper.

<?php
$string="FARIDUL";
$string_to_upper=strtoupper("$string");
echo $string_to_upper;
?>

How to reverse string in php

<?php
$string="FARIDUL";
$string_rev=strrev("$string");
echo $string_rev;
?>

How to use date() function in php

<?php
//backdate
$backdate= strtotime("-1 week");
echo date("d-m-y\n",$backdate);
//next date
$backdate= strtotime("+1 week");
echo date("d-m-y\n",$backdate);
//back 1 year
$backdate= strtotime("-1 year");
echo date("d-m-y\n",$backdate);
//next two week
$backdate= strtotime("+3 years");
echo date("d-m-y\n",$backdate);
?>

How to use explode and implode function


//explode function 

<?php
$string="WWW rootitech com";
$explode=explode(" ",$string);
$mini=2-2;
echo $explode[$mini];
 ?>

//explode and implode function

<?php
$string="www.rootitech.com";
$explode=explode(".",$string);
$implode=implode($explode,"@");
echo $implode;*/
?>

How to show limited content in php

<?php
$string="finch data software";

$mb_substr=mb_substr($string,0,8);
echo $mb_substr;
?>

Thursday, November 6, 2014

How to setting PHP Sessions

Firstly   type this code and save set.php


<?php
session_start();
$_SESSION['username']='faridul';
?>

Secondly type this code and save view.php:

<?php
    session_start();
   
    if(isset($_SESSION['username'])){
        $seevariavle= $_SESSION['username'];
        echo 'Welcome,' .$seevariavle;
   
    }
    else{
        echo "Please log in.";
   
    }
?>

 Result: browsers show ----Welcome faridul.

Thirdly type this code and save unset.php :

<?php
    session_start();   
    unset($_SESSION['username']);
?>

You see result such step: 1.visit view.php then visit unset.php.
finally visit view.php see result "Please log in"

How to use $_GET variable

<?php
    if(isset($_GET['day']) && isset($_GET['date']) && isset($_GET['year'])){
       
        $day=$_GET['day'];
        $date=$_GET['date'];
        $year=$_GET['year'];
   
        if(!empty($day) && !empty ($date) && !empty ($year)){
            echo "ok";
        }
       
        else{
            echo "please fill the field";
        }
    }


?>

<form action ="get_variable.php" method="GET">
    Day: <br /><input type="text" name="day"><br />
    Date: <br /><input type="text" name="date"><br />
    Year: <br /><input type="text" name="year"><br /><br />
    <input type="submit" value="submit">
</form>

Wednesday, November 5, 2014

Top Oldest sports in the World ~ Come First Take News

Top Oldest sports in the World ~ Come First Take News

How to detect visitor's browsers

part 1:
<?php
    $browser= get_browser(null,true);
    print_r ($browser);

?> 

 part2:

<?php
    $browser= get_browser(null,true);
    echo $browser['browser'];

?>

How to get visitor ip address

How to get visitor ip address:

<?php
    $ip_address=$_SERVER['REMOTE_ADDR'];
    echo $ip_address;

?>

Better way to get visitor ip address:

<?php
    $http_client_ip= $_SERVER['HTTP_CLIENT_IP'];
    $http_x_forwared_for=$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote_addr= $_SERVER ['REMOTE_ADDR'];
   
   
    if(! empty ($http_client_ip)){
   
        $ip_address=$http_client_ip;
    }
   
    else if(!empty ($http_x_forwared_for)){
   
        $ip_address=$http_x_forwared_for;
   
    }
   
    else {
        $ip_address=$remote_addr;
    }
   
    echo $ip_address;


?>

Using the Header to force page direct

How to use Header to force page direct:

<?php
    $redirect_page='http://google.com';
    $redirect=true;
   
    header('Location: '.$redirect_page);

?>

SERVER Script Variable

SERVER Script Variable:
=>$_SERVER['SCRIPT_NAME'];
=>$_SERVER['HTTP_HOST'];

Useful function of php

Most useful function of php:

=> rand()   ---------    that is except value randomly not from user.
      Exam:  code
                  <?php
                  $rand= rand();
                   echo $rand;
                     ?>
        output: 21417
=> getrandmax() ------------   that is except maximum value.
<?php ob_start(); ?>
<h1> my page</h1>
<?php
    $redirect_page='http://google.com';
    $redirect=false;
    if($redirect==true){
        header('Location: '.$redirect_page);
    }
  
    ob_end_flush();
?>

strpos function

mixed strpos (string $haystack,mixed $needle [, int $offset = 0])

find the numeric position of the first occurrence of needle in the haystack string.

Parameters:

=> haystack: The string that is searched
=> needle :it is not a string.it is converted to an integer and applied as the ordinal value of a character.
=>offset: if specified,search will start this number of characters counted from the beginning of the string.offset is not negative.   
 

<?php
$string
'abc';$find   'a';$pos strpos($
string$find  );
// Note our use of ===.  Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
    echo 
"The string '$find' was not found in the string '$
string'";
} else {
    echo 
"The string '$find' was found in the string '$
string'";
    echo 
" and exists at position $pos";
}
?>

Saturday, October 18, 2014

Numbering System: Part-1

Numbering System: Part-1


How did the counting process start?

At the very beginning, the ancient people count something with the help of small pieces of stones or with the help of likely solid substances. But it is no more comfortable way when they learnt to scratch on the surface of the stones and on the wall of the cave or on the ground. They scratched a single line for each single thing they ware counting. But it was not again comfortable for large number of things. So they changed the way. They took more symbols and start counting and this time it was more easier than before. But what was the logic behind their counting system?

Lets go for a overview of mostly used decimal numbering system. Here the base is ten. It is called the radix of the decimal numbering system. Here we can say the there are ten basic symbols. The ten basic symbols are '0','1','2','3','4','5','6','7','8','9'. Probably you have noticed that obviously there is an order. So we can say that decimal number is based on ten basic ordered symbol. Probably it is not so clear to you. Now come to the point, count zero to forty-nine and write it. Here is the form:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

Now place an extra 0 before the single numbers. Here my intention is to upgrade every number to two digit. Now this is the form:
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49


Now look at the first digit of the first ten numbers. Yap, you are right, it is 0 (zero) then look at the second digit and you will see that it is the basic ordered symbols. Now look at the first digit of the next ten numbers. You are right, it is 1, the second basic ordered symbol. And now look at the second digits, it is again the ten basic ordered symbol you have noticed for the case of 0 as the first digit. Do this again and again for the next ten numbers. If we assume that two or more basic symbols form the secondary single symbol. For example, 1 and 2 makes 12, here 1 and 2 are basic symbols and 12 is secondary symbol. Then it is always true that the ordered basic symbols will be repeating after every ten numbers and the previous secondary symbol increased by one after every period. This is the logic behind the decimal numbering system.