artdvp
9/7/2017 - 3:06 PM

PHP func

<?php 

	$str = "Test String world";
	echo strlen($str); //count string
	echo "<hr>";
	//11

	echo strpos($str,"world"); //search string
	echo "<hr>";
	//12
	//
	
	$str = "  username  ";
	echo trim($str); // delete space
	// username
	// 
	echo "<hr>";
	$str2 = "<strong>PHP<strong/>";
	echo htmlspecialchars($str2); //shiw html tags
	//<strong>PHP<strong/>
	// 
	echo "<hr>";
	echo strip_tags($str2); //cut tags html
	//PHP
	//
	echo "<hr>";
	$str3 = "Hello ,world , ma ,de ,na";
	echo wordwrap($str3,10 ,"<br>"); //wordwrap space
	/*
	Hello
	,world ,
	ma ,de ,na
	 */
	//
	echo "<hr>";
	$strnumber = "one-two-three-four";
	$strnum = explode("-", $strnumber);
	echo $strnum[0] . " " . $strnum[1]; //explode with value
	//one two
	//
	echo "<hr>";
	$str = "apple";
	$strmd5 = md5($str);  //encryp
	echo $strmd5;
	//1f3870be274f6c49b3e31a0c6728957f
	if($strmd5 === md5("apple")){
		echo "<br>ok"; //ok
	}else{
		echo "<br>no ok";
	}
	//
	echo "<hr>";
	$str4 = "Hello ,world";
	echo substr($str4,2,4);  //substring (string,start,count)
	//llo
	echo "<hr>";
	echo rand();  //random number 
	echo "<br>";
	echo rand(5,10); //rang random (from,to)

	echo max(5,25,-30); //max value
	//25
	//
	echo "<hr>";
	$number = 121324.356;
	echo number_format($number,3); //format number value (value,floating point)
	//121,324.356

 ?>