
Hàm substr_count() trong PHP - PHP Function
Sử dụng hàm substr_count() với 2 tham số: Code $string = "This is an example string"; $result = substr_count($string, "is"); echo $result; Kết quả 2

Hàm substr_replace() trong PHP - PHP Function
Sử dụng hàm substr_replace() thay thế toàn bộ chuỗi: Code $var = 'This is something'; echo $var . "<br />"; echo substr_replace($var, 'this is replace', 0) . "<br />"; echo substr_replace($var, 'this is replace', 0, strlen($var)) . "<br ...

Hàm substr() trong PHP - PHP Function
Code echo $rest = substr("abcdef", 0, 3) . "<br />"; echo $rest = substr("abcdef", 0, -1) . "<br />"; echo $rest = substr("abcdef", 2, -1) . "<br />"; if (substr("abcdef", 4, -4) == false) { echo 'false' . "<br />"; } echo $rest = ...

Hàm trim() trong PHP - PHP Function
Code $text = " ------This is a test -- string :) ... "; $hello = "Hello World"; var_dump($text); echo "<br />"; var_dump($hello); echo "<br />"; $trimmed = trim($text); var_dump($trimmed); echo "<br />"; $trimmed = trim($text, " ...

Hàm ucfirst() trong PHP - PHP Function
Code echo ucfirst("Zaidap.com.net") . "<br />"; echo ucfirst("this is a test") . "<br />"; echo ucfirst("FREETUTS.NET") . "<br />";

Hàm ucwords() trong PHP - PHP Function
Code echo ucwords("Zaidap.com.net", ".") . "<br />"; echo ucwords("this is a te.st", " .") . "<br />"; echo ucwords("FREETUTS.NET") . "<br />";

Hàm wordwrap() trong PHP - PHP Function
Cách sử dụng hàm wordwrap: Code $text = "this is a test stringgggggggggggggggggggggggg"; echo $newtext = wordwrap($text, 20, "-")."<br />"; echo $newtext = wordwrap($text, 8, "-", true)."<br />"; echo $newtext = wordwrap($text, 8, "-", ...

Hàm md5() trong PHP - PHP Function
$str = 'Zaidap.com.net'; echo md5($str); // 83617175fd8cf470d4af657a28def98e // hoặc echo md5($str, false); // 83617175fd8cf470d4af657a28def98e

Hàm sha1() trong PHP - PHP Function
$str = 'Zaidap.com.net'; echo sha1($str); // kêt quả: 8d9fa09de2e997d8fbb544326b84d1f894cd3ca3 echo sha1($str, false); // kêt quả: 8d9fa09de2e997d8fbb544326b84d1f894cd3ca3

Hàm md5_file() trong PHP - PHP Function
<?php $file = 'Zaidap.com.txt'; echo md5_file($file, false); // d41d8cd98f00b204e9800998ecf8427e ?>

Hàm hash_algos() trong PHP - PHP Function
Code $arr = hash_algos(); echo "<pre>"; print_r($arr); echo "</pre>";

Hàm hash() trong PHP - PHP Function
Mã hóa theo kiểu "ripemd160": Code echo hash('ripemd160', 'The quick brown fox jumped over the lazy dog.') . "<br />"; echo hash('ripemd160', 'The quick brown fox jumped over the lazy dog.', true); Kết quả ...

Hàm hash_init() trong PHP - PHP Function
Code $ctx = hash_init('md5'); hash_update($ctx, 'This a test string'); echo hash_final($ctx);

Hàm hash_update() trong PHP - PHP Function
Code $ctx = hash_init("md5"); echo hash_update($ctx, "this is a test") . "<br />"; echo hash_final($ctx) . "<br />"; echo md5("this is a test");

Hàm hash_final() trong PHP - PHP Function
Code $ctx = hash_init("md5"); hash_update($ctx, "this is a test") . "<br />"; echo hash_final($ctx) . "<br />";

Hàm hash_copy() trong PHP - PHP Function
Code $ctx = hash_init('md5'); hash_update($ctx, 'This is a test'); $copy = hash_copy($ctx); echo hash_final($ctx). "<br />"; echo hash_final($copy). "<br />";

Hàm hash_file() trong PHP - PHP Function
Code //tạo file mới file_put_contents("test.txt", "this is a test file content"); echo hash_file("md5", "test.txt");

Hàm hash_equals() trong PHP - PHP Function
Code $expected = crypt('Zaidap.com.net', '$thisismysalt$'); $correct = crypt('Zaidap.com.net', '$thisismysalt$'); $incorrect = crypt('soccer', '$thisismysalt$'); var_dump(hash_equals($expected, $correct)); echo "<br />"; var_dump(hash_equals($expected, ...

Hàm array() trong PHP - PHP Function
$bien = array(); echo '<pre>'; print_r($bien);

Hàm array_chunk() trong PHP - PHP Function
$input_array = array('a', 'b', 'c', 'd', 'e'); echo '<pre>'; // Gom nhóm với mỗi nhóm là 2 phần tử print_r(array_chunk($input_array, 2));