Posts

Showing posts from June, 2022

#88. PHP Date_create & Date_format Function

Image
 How to work  PHP Date_create & Date_format Function? Syntax: Run code: <?php // For future and past date set $date = date_create( "2038-03-22 22:33:32" , timezone_open( "Asia/Karachi" )) ; echo date_format($date , "d/m/y H:i:s" ) ; ? >

#87. PHP Mktime & Gmmktime Function

Image
 How to work  PHP Mktime & Gmmktime Function? Syntax: Run Code: <?php echo "Time & Date is :" . date( "d-m-y h:i:sa" ) . "<br>" ; echo date( "d-m-y h:i:sa" , mktime( 0 , 0 , 0 , 06 , 19 , 2001 )) . "<br>" ; echo date( "d-m-y h:i:sa" , gmmktime( 0 , 0 , 0 , 06 , 19 , 2001 )) . "<br>" ; ? > O/P

#86. PHP Time Function

Image
 How to work Tme Function? Syntax: Run code: <?php echo "Hour is :" . date( "h" ) . "<br>" ; echo "Hour is :" . date( "H" ) . "<br>" ; echo "Hour is :" . date( "g" ) . "<br>" ; echo "Hour is :" . date( "G" ) . "<br>" ; echo "-------Minutes--------" . "<br>" ; echo "Minutes is :" . date( "i" ) . "<br>" ; echo "-------Seconds--------" . "<br>" ; echo "Seconds is :" . date( "s" ) . "<br>" ; echo "-------AM & PM--------" . "<br>" ; echo "Meridiem is :" . date( "A" ) . "<br>" ; echo "-------Time--------" . "<br>" ; echo "Time is :" . date( "h:i:sa" ) . "<br>" ; echo "-------...

#85. PHP Date Function

Image
 How to work  PHP Date Function? Syntax: Run Code: <?php // echo "Today is :" . date( "d" ) . "<br>" ; echo "Today is :" . date( "j" ) . "<br>" ; echo "Today is :" . date( "jS" ) . "<br>" ; echo "Month is :" . date( "F" ) . "<br>" ; echo "Month is :" . date( "m" ) . "<br>" ; echo "Month is :" . date( "n" ) . "<br>" ; echo "Month is :" . date( "M" ) . "<br>" ; echo "Year is :" . date( "Y" ) . "<br>" ; echo "Year is :" . date( "y" ) . "<br>" ; echo "Full Date is :" . date( "d/m/Y" ) . "<br>" ; echo "Full Date is :" . date( "d-m-Y" ) . "<br>" ; echo "--------Week Day----...

#85. PHP Math Rand, Mt_rand & Lcg_value Functions

Image
How to work  PHP Math Rand, Mt_rand & Lcg_value Functions? Syntax: Run Code: <?php echo "----------Rand--------------" . "<br>" ; // Rand return everytime change value after Reload browser echo (rand() . "<br>" ) ; echo (rand() . "<br>" ) ; echo (rand( 0 , 10 ) . "<br>" ) ; echo "----------Mt_Rand--------------" . "<br>" ; // Mt_Rand 4 time faster then rand.. Mt_Rand also return everytime change value after Reload browser echo (mt_rand() . "<br>" ) ; echo (mt_rand() . "<br>" ) ; echo (mt_rand( 0 , 10 ) . "<br>" ) ; echo "------------lcg_value------------" . "<br>" ; // lcg_value float value return everytime change value after Reload browse echo (lcg_value() . "<br>" ) ; ? >

#83. PHP Math Intdiv, Sqrt, Pow Functions

Image
 How to work Math Intdiv, Sqrt, Pow Functions? E.g Run Code: <?php // Devided function echo intdiv( 5 , 5 ) . "<br>" ; echo intdiv( 5 , 10 ) . "<br>" ; echo intdiv( - 15 ,- 5 ) . "<br>" ; ?> Pow Syntax: Run Code: <?php // power of echo pow( 5 , 4 ) . "<br>" ; echo pow( 10 , 4 ) . "<br>" ; echo pow( 9 , 2 ) . "<br>" ; ? > Sqrt Syntax: <?php // Square Function echo sqrt( 5 ) . "<br>" ; echo sqrt( 10 ) . "<br>" ; echo sqrt( 9 ) . "<br>" ; ?>

#82. PHP Math Ceil Floor Round Abs Functions

Image
 How to work  PHP Math Ceil Floor Round Abs Functions? Syntax: Run Code: <?php // Ceil return upper value // echo (ceil(0.83). "<br>"); // echo (ceil(0.30). "<br>"); // echo (ceil(5.1). "<br>"); // echo (ceil(-3). "<br>"); // Floor return less value echo (floor( 0 . 83 ) . "<br>" ) ; echo (floor( 0 . 30 ) . "<br>" ) ; echo (floor( 5 . 1 ) . "<br>" ) ; echo (floor( - 3 . 7 ) . "<br>" ) ; // Round if 5.3 less to return 5 and whlie 5.8 ot return 6 echo (round( 0 . 83 ) . "<br>" ) ; echo (round( 0 . 30 ) . "<br>" ) ; echo (round( 5 . 1 ) . "<br>" ) ; echo (round( 5 . 7 ) . "<br>" ) ; echo (round( - 3 ) . "<br>" ) ; // absolute return actual value and positive value echo (abs( 0 . 81 ) . "<br>" ) ; echo (abs( 0 . 1 ) . "<br>" ) ; echo (abs( ...

#81. PHP Math Min & Max Functions

Image
 How to work  PHP Math Min & Max Functions? Syntax: Run Code: <?php // $val = max(21,12,32,33,434,54,32); // $val = min(21,12,32,33,434,54,32); //$val = min(array(21,12,32,33,434,54,32,8)); // Two Array function // $val = min(array(21,12,32), array(33,32,8)); // $val = max(array(21,12,32), array(33,32,8)); // Boolean type Function $val = max( TRUE , FALSE ) ; $val = min( TRUE , FALSE ) ; // echo $val; echo "<pre>" ; print_r($val) ; echo "</pre>" ; ? >

#80. PHP Strip_tags & Wordwrap Function

Image
 How to work  PHP Strip_tags & Wordwrap Function? Strip Syntax: Run Code: <?php // Strip tag Remove the All Tags $str = "Hell <b>Sheikh</b>, Hello <i>World</i>" ; echo strip_tags($str , "<b>" ) ;   // <i> Remove tag ? > Wordwrap Syntax: Run code: <?php $str = "This is a chair" ; echo wordwrap($str , 3 , "<br>" , TRUE ) ; ? >

#79. PHP Chr & Ord Function

Image
 How to work  PHP Chr & Ord Function? ASCII Values : Chr Syntax: Run Code: <?php $str = chr( 0120 ) ;   // Hex = 0120, Octal = 4x34 etc echo $str ; ? > Ord Syntax: Run Code <?php $str = ord( "A" ) ; echo $str ; ? >

#78. PHP bin2hex & hex2bin Function

Image
 How to work  PHP bin2hex & hex2bin Function? Syntax: Run code: <?php // echo bin2hex("Aqib 1995"); $str = bin2hex( "Aqib Saeed" ) ; echo $str . "<br>" ; echo hex2bin($str) ; ? >

#77. PHP Convert_uuencode & Convert_uudecode Function

Image
 How to work  PHP Convert_uuencode & Convert_uudecode Function? Syntax: Run Code: <?php $str = "Hello world" ; // echo convert_uuencode($str). "<br>"; // echo convert_uudecode($str); $encodeString = convert_uuencode($str) ; echo $encodeString ; $decodeString = convert_uudecode($encodeString) ; echo $decodeString ; // Note MD5 and Sha1 not convert into decript data while we can convert into convert_uuencode and convert_uudecode ? >

#76. PHP Md5 & Sha1 Function

Image
 How to work  PHP Md5 & Sha1 Function? Syntax: Run Code: <?php $str = "Hello" ; echo "The String :" . $str . "<br>" ; // convert to Binary format echo "md5 Binary : " . md5($str , TRUE ) . "<br>" ; // Convert to HEXA format 32 chars echo "md5 HEXA : " . md5($str) . "<br>" ; Sha1 Binary stronger chars on 20 chars echo "Sha1 Binary : " . sha1($str , TRUE ) . "<br>" ; echo "Sha1 HEX : " . sha1($str) . "<br>" ; if (md5($str) == "8b1a9953c4611296a827abf8c47804d7" ){     echo "Password Marched :" ; } ? >

#75. PHP Htmlentities & Htmlspecialchars Functions

Image
 How to work PHP Htmlentities & Htmlspecialchars Function? Syntax: Run Code: <?php $str   = "This is 'PHP' <b>Programming.</b>" ; $str = '<a href="https://sheikh1996.blogspot.com">PHP Dev Website</a>' ; echo $str . "<br>" ; //echo htmlentities($str, ENT_QUOTES); // echo htmlentities($str, ENT_NOQUOTES); // echo htmlspecialchars($str, ENT_NOQUOTES); // echo htmlspecialchars($str, ENT_QUOTES); //$htmlEnt = htmlspecialchars($str, ENT_NOQUOTES); $htmlEnt = htmlspecialchars($str , ENT_NOQUOTES) ; echo $htmlEnt ; //echo html_entity_decode($htmlEnt); echo htmlspecialchars_decode($htmlEnt) ; //-------------------------------------- echo "<pre>" ; //print_r(get_html_translation_table(HTML_SPECIALCHARS)); print_r(get_html_translation_table(HTML_ENTITIES)) ; echo "</pre>" ; ? >

#74. PHP String Addslashes & Stipslashes Functions

Image
 How to work  PHP String Addslashes & Stipslashes Functions? Syntax: Run Code: <?php $str = "Hello I am 'Aqib Saeed'" ; echo $str . "<br>" ; //  echo addslashes($str) . "<br>"; // $newStr = addslashes($str); //$newStr = addcslashes($str, "A"); $newStr = addcslashes($str , "A..Z" ) ; //a..z //stripslashes remove slashes //stripcslashes // echo stripslashes($newStr); echo $newStr ; ? >

#73. PHP String Trim & Chop Functions

Image
 How to work  PHP String Trim & Chop Functions? Syntax: Run Code: <?php $str = "Hello World   " ; echo $str . "<br>" ; // echo trim($str, "H");   // H, Hld,etc // echo rtrim($str, "ld"); // echo ltrim($str, "Hld"); // for space // echo trim($str); echo chop ($str , "world" ) ; ? >

#72. PHP String Str_Pad & Str_Repeat Functions

Image
 How to work  PHP String Str_Pad & Str_Repeat Functions? Run Code: <?php $str = "Hello World" ; //echo str_pad($str, 23,"-"); // echo str_pad($str, 23,"-", STR_PAD_BOTH); echo str_repeat($str , 5 ) ; ? >

#71. PHP String Strrev & Str_shuffle Functions

Image
 How to work  PHP String Strrev & Str_shuffle Functions? Syntax  Run Code: <?php // strrev Reverce letter echo strrev( "Hello" ) ; // str_shuffle letter movement echo str_shuffle( "Hello" ) ; ? >

#70. PHP String Compare Functions

Image
 How to work  PHP String Compare Functions? Syntax & E.g Run Code: <?php echo strcmp( "Hello World" , "Hello World Hello" ) ; // strncmp means length echo strncmp( "Hello World" , "hello World Hello" , 5 ) ; // strcasecmp echo strcasecmp( "HeLLo World" , "hello World World" ) ; //strncasecmp echo strncasecmp( "HeLLo World" , "hello World World" , 5 ) ; ?> How to Work Sub String Compare Function? Run Code: <?php //substr_compare echo substr_compare( "HeLLo world" , "World" , 0 , 3 ) ; ?> How to Work Similar Text Function? Run code: <?php //similar_text means only matching the characters echo similar_text( "HeLLo world" , "hi World " , $per) ; echo "Percentage :"   . $per ; ? >

#69. PHP String Replace Functions

Image
 How to work  PHP String Replace Functions? Syntax & E.g. Run Code: <?php $str = "I love Programming. I am a Programmer" ; $find = ["I","love", "Programming"]; $replace = ["","Hi","Programmer"]; echo str_replace("love", " ", $str); echo str_replace($find, $replace, $str); str_ireplace case-insensitive echo str_ireplace($find, $replace, $str); ? > Run Code: <?php $str = "I love Programming. I am a Programmer" ; // $find = ["I","love", "Programming"]; // $replace = ["","Hi","Programmer"]; //$array = ["Civic","Corola","Alto"]; //substr_replace //echo substr_replace($str, "Programmer",7,13); // Replace in Array function // echo "<pre>"; // print_r(str_replace("Civic", "Sazuki",$array)); // echo "</pre>"; ? > Run Code: <...