Saturday, 8 June 2013

Basic functions : PHP


Some of the basic functions and data manipulation in PHP are given below:
 
$str_1 = " DeveloperDK Blogspot ";
  • echo "DK_".$str_1."_DK";                // --> DK _ DeveloperDK Blogspot _ DK
  • echo "DK_".trim($str_1)."_DK";       // --> DK_ DeveloperDK Blogspot _DK
  • echo strtolower($str_1);                    // --> developerdk blogspot
  • echo strtoupper($str_1);                    // --> DEVELOPERDK BLOGSPOT 
                       
$str_2 = "developerdk Blogspot";
  • echo ucwords($str_2);                       // --> Developerdk Blogspot
                       
$str_3 = "deVeloperdk BloGspot";
  • echo ucwords(strtolower($str_3));                 // --> Developerdk Blogspot
  • echo substr($str_3,0,5);                                 // --> deVel
  • echo substr($str_3,0,-4);                               // --> deVeloperdk BloGspot
  • echo substr($str_3,4);                                    // --> loperdk BloGspot
  • echo substr($str_3,-4);                                  // --> spot
                       
$str_4 = "Developer";
$str_5 = 11;
  • echo is_string($str_4);                        // --> o/p : 1
  • echo is_string($str_5);                        // --> no o/p                    

$str_6 ="100.00";
  • echo intval($str_6);                            // --> 100
                       
$str_7 = 2.3;
  • echo is_float($str_7);                         // --> o/p : 1

No comments:

Post a Comment