I am Know Some usefull php function for generally use.
1) str_word_count
<? php
/*==UseFull Php Function == */
$str = "Hello My Informaation";
echo str_word_count( $str); //Outputs 3
?>
This functionusefull for count the word in stirng .
2) substr ( string, start, length)
this function use for returns a part of a string.
<? php
echo substr ( "Lorem Ipsum is simply dummy text of the printing and typesetting industry", 2,10); //Outputs rem Ipsum
?>
you can also use as only start lenght check below exmaple
<? php
echo substr ( "Hello jaydip ", 6); //Outputs jaydip
?>
3) get_browser( );
you can use get your current browser detail.
<? php
echo $_SERVER[ 'HTTP_USER_AGENT'];
$browser = get_browser( );
print_r( $browser); //check the output in your brower
?>
4) uniqid
This function is forgenerates a unique ID based on the microtime .
<? php
echo uniqid ( ); //output : every time different.
?>
you can also use as add prefix
<? php
echo uniqid ( 'jaydip '); //output will be like jaydip54abcfc3d5421( uniqid code will be change )
//jaydip is prefix
?>
5)date
This function return system current date.
<? php
echo date( 'd m y ');
?>
check for this link.
http://www.w3schools.com/php/func_date_date.asp
6) print_r
this use to return array value.
<? php
$test = array( "car","bus","train");
print_r( $test); //outputs Array ( [0] => car [1] => bus [2] => train )
?>
6) implode
this function return returns a string from the elements of an array.
<? php
$data = array( "mayur ", "javed ", "prasant ", "hiren ", "nehal ");
echo implode( ", ", $data); //output mayur , javed , prasant , hiren , nehal
?>
you can implode any of like . (dots ), pipe( |), change first parameter.
<? php
echo implode( "|", $data); //output mayur | javed | prasant | hiren | nehal
?>
7) explode
this function breaks a string into an array.
<? php
$str = "i am walking in my village";
print_r (explode( " ", $str)); //outputs Array ( [0] => i [1] => am [2] => walking [3] => in [4] => my [5] => village )
?>
<
/*==
$str = "Hello My Informaation";
?>
This function
<
?>
<
?>
<
$browser = get_browser
print_r
?>
This function is for
<
?>
<
//
?>
5)
This function return system current date.
<
?>
http://www.w3schools.com/php/func_date_date.asp
<
$test = array
print_r
?>
<
$data = array
?>
<
?>
<
$str = "
print_r (explode
?>
0 komentar:
Post a Comment