<?php 
$txt="Hello world!"; 
echo $txt; 
?>

<?php
$txt1="Hello world!";
$txt2="What a nice day!";
echo $txt1 . " " . $txt2;
?>

<?php
echo strlen("Hello world!");
?>

<?php
echo strpos("Hello world!","world");
?>

<?php 
$str = addcslashes("Hello World!","W");
echo($str); 
?>

<?php
$str = "Welcome to my humble Homepage!";
echo $str."<br>";
echo addcslashes($str,'m')."<br>";
echo addcslashes($str,'H')."<br>";
?>

<?php
$str = "Welcome to my humble Homepage!";
echo $str."<br>";
echo addcslashes($str,'A..Z')."<br>";
echo addcslashes($str,'a..z')."<br>";
echo addcslashes($str,'a..g');
?>

<?php
$str = addslashes('What does "yolo" mean?');
echo($str);
?>

<?php
$str = "Who's Peter Griffin?";
echo $str . " This is not safe in a database query.<br>";
echo addslashes($str) . " This is safe in a database query.";
?>

<?php
$str = bin2hex("Hello World!");
echo($str);
?>

<?php
$str = "Hello world!";
echo bin2hex($str) . "<br>";
echo pack("H*",bin2hex($str)) . "<br>";
?>

<?php
$str = "Hello World!";
echo $str . "<br>";
echo chop($str,"World!");
?>

<?php
$str = "Hello World!\n\n";
echo $str;
echo chop($str);
?>

<!DOCTYPE html>
<html>

<body>

Hello World!

Hello World!

</body>
</html>

<?php
echo chr(52) . "<br>"; // Decimal value
echo chr(052) . "<br>"; // Octal value
echo chr(0x52) . "<br>"; // Hex value
?>

<?php
$str = chr(43);
$str2 = chr(61);
echo("2 $str 2 $str2 4");
?>

<?php
$str = "Hello world!";
echo chunk_split($str,1,".");
?>

<?php
$str = "Hello world!";
echo chunk_split($str,6,"...");
?>

<?php
$str = "Hello world! æøå";
echo $str . "<br>";
echo convert_cyr_string($str,'w','a');
?>

<?php
$str = ",2&5L;&@=V]R;&0A `";
echo convert_uudecode($str);
?>

<?php
$str = "Hello world!";
// Encode the string
$encodeString = convert_uuencode($str);
echo $encodeString . "<br>";

// Decode the string
$decodeString = convert_uudecode($encodeString);
echo $decodeString;
?>

<?php
$str = "Hello world!";
echo convert_uuencode($str);
?>

<?php
$str = "Hello world!";
// Encode the string
$encodeString = convert_uuencode($str);
echo $encodeString . "<br>";

// Decode the string
$decodeString = convert_uudecode($encodeString);
echo $decodeString;
?>

<?php
$str = "Hello World!";
echo count_chars($str,3);
?>

<?php
$str = "Hello World!";
echo count_chars($str,4);
?>

<?php
$str = "Hello World!";
print_r(count_chars($str,1));
?>

<?php
$str = "PHP is pretty fun!!";
$strArray = count_chars($str,1);

foreach ($strArray as $key=>$value)
{
    echo "The character <b>'".chr($key)."'</b> was found $value time(s)<br>";
}
?>

<?php
$str = crc32("Hello World!");
printf("%un",$str);
?>

<?php
$str = crc32("Hello world!");
echo 'Without %u: '.$str."<br>";
echo 'With %u: ';
printf("%u",$str);
?>

<?php
$str = crc32("Hello world.");
echo 'Without %u: '.$str."<br>";
echo 'With %u: ';
printf("%u",$str);
?>

<?php
$hashed_password = crypt('mypassword'); // 自动生成盐值

/* 你应当使用 crypt() 得到的完整结果作为盐值进行密码校验,以此来避免使用不同散列算法导致的问题。(如上所述,基于标准 DES 算法的密码散列使用 2 字符盐值,但是基于 MD5 算法的散列使用 12 个字符盐值。)*/
if (hash_equals($hashed_password, crypt($user_input, $hashed_password))) {
    echo "Password verified!";
}
?>

<?php
// 设置密码
$password = 'mypassword';

// 获取散列值,使用自动盐值
$hash = crypt($password);
?>

<?php
if (CRYPT_STD_DES == 1) {
    echo 'Standard DES: ' . crypt('rasmuslerdorf', 'rl') . "\n";
}

if (CRYPT_EXT_DES == 1) {
    echo 'Extended DES: ' . crypt('rasmuslerdorf', '_J9..rasm') . "\n";
}

if (CRYPT_MD5 == 1) {
    echo 'MD5:          ' . crypt('rasmuslerdorf', '$1$rasmusle$') . "\n";
}

if (CRYPT_BLOWFISH == 1) {
    echo 'Blowfish:     ' . crypt('rasmuslerdorf', '$2a$07$usesomesillystringforsalt$') . "\n";
}

if (CRYPT_SHA256 == 1) {
    echo 'SHA-256:      ' . crypt('rasmuslerdorf', '$5$rounds=5000$usesomesillystringforsalt$') . "\n";
}

if (CRYPT_SHA512 == 1) {
    echo 'SHA-512:      ' . crypt('rasmuslerdorf', '$6$rounds=5000$usesomesillystringforsalt$') . "\n";
}
?>

<?php
echo "Hello world!";
?>

<?php
$str = "Hello world!";
echo $str;
?>

<?php
$str = "Hello world!";
echo $str;
echo "<br>What a nice day!";
?>

<?php
$str1="Hello world!";
$str2="What a nice day!";
echo $str1 . " " . $str2;
?>

<?php
$age=array("Peter"=>"35");
echo "Peter is " . $age['Peter'] . " years old.";
?>

<?php
echo "This text
spans multiple
lines.";
?>

<?php
echo 'This ','string ','was ','made ','with multiple parameters.';
?>

<?php
$color = "red";
echo "Roses are $color";
echo "<br>";
echo 'Roses are $color';
?>

<?php
$color = "red";
?>

<p>Roses are <?=$color?></p>

<?php
$str = "www.runoob.com";
print_r (explode(".",$str));
?>

<?php
$str = 'one,two,three,four';

//  返回包含一个元素的数组
print_r(explode(',',$str,0));
print "<br>";

// 数组元素为 2
print_r(explode(',',$str,2));
print "<br>";

// 删除最后一个数组元素
print_r(explode(',',$str,-1));
?>

<?php
$number = 9;
$str = "Beijing";
$file = fopen("E:\\test.txt","w");
echo fprintf($file,"There are %u million bicycles in %s.",$number,$str);
?>

<?php
$number = 123;
$file = fopen("test.txt","w");
fprintf($file,"%f",$number);
?>
<?php
$number = 123;
$file = fopen("E:\\test.txt","w");
fprintf($file,"With 2 decimals: %1$.2f
nWith no decimals: %1$u",$number);
?>

<?php
$num1 = 123456789;
$num2 = -123456789;
$char = 50; // The ASCII Character 50 is 2

// Note: The format value "%%" returns a percent sign
printf("%%b = %b <br>",$num1); // Binary number
printf("%%c = %c <br>",$char); // The ASCII Character
printf("%%d = %d <br>",$num1); // Signed decimal number
printf("%%d = %d <br>",$num2); // Signed decimal number
printf("%%e = %e <br>",$num1); // Scientific notation (lowercase)
printf("%%E = %E <br>",$num1); // Scientific notation (uppercase)
printf("%%u = %u <br>",$num1); // Unsigned decimal number (positive)
printf("%%u = %u <br>",$num2); // Unsigned decimal number (negative)
printf("%%f = %f <br>",$num1); // Floating-point number (local settings aware)
printf("%%F = %F <br>",$num1); // Floating-point number (not local settings aware)
printf("%%g = %g <br>",$num1); // Shorter of %e and %f
printf("%%G = %G <br>",$num1); // Shorter of %E and %f
printf("%%o = %o <br>",$num1); // Octal number
printf("%%s = %s <br>",$num1); // String
printf("%%x = %x <br>",$num1); // Hexadecimal number (lowercase)
printf("%%X = %X <br>",$num1); // Hexadecimal number (uppercase)
printf("%%+d = %+d <br>",$num1); // Sign specifier (positive)
printf("%%+d = %+d <br>",$num2); // Sign specifier (negative)
?>

<?php
print_r (get_html_translation_table()); // HTML_SPECIALCHARS is default.
?>

<?php
print_r (get_html_translation_table(HTML_SPECIALCHARS));
?>

<?php
print_r (get_html_translation_table(HTML_ENTITIES));
?>

<?php
echo hebrev("á çùåï äúùñâ");
?>
<?php
echo hebrevc("á çùåï äúùñâ\ná çùåï äúùñâ");
?>

<?php
echo hex2bin("48656c6c6f20576f726c6421");
?>

<?php
$str = "&lt;&copy; W3CS&ccedil;h&deg;&deg;&brvbar;&sect;&gt;";
echo html_entity_decode($str);
?>

<?php
$str = "Jane &amp; &#039;Tarzan&#039;";
echo html_entity_decode($str, ENT_COMPAT); // Will only convert double quotes
echo "<br>";
echo html_entity_decode($str, ENT_QUOTES); // Converts double and single quotes
echo "<br>";
echo html_entity_decode($str, ENT_NOQUOTES); // Does not convert any quotes
?>

<?php
$str = "My name is &Oslash;yvind &Aring;sane. I&#039;m Norwegian.";
echo html_entity_decode($str, ENT_QUOTES, "ISO-8859-1");
?>

<?php
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars($str);
?>

<?php
$str = "Jane & 'Tarzan'";
echo htmlspecialchars($str, ENT_COMPAT); // 默认,仅编码双引号
echo "<br>";
echo htmlspecialchars($str, ENT_QUOTES); // 编码双引号和单引号
echo "<br>";
echo htmlspecialchars($str, ENT_NOQUOTES); // 不编码任何引号
?>

<?php
$str = 'I love "PHP".';
echo htmlspecialchars($str, ENT_QUOTES); // 编码双引号和单引号
?>
;

<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
?>

<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr)."<br>";
echo implode("+",$arr)."<br>";
echo implode("-",$arr)."<br>";
echo implode("X",$arr);
?>

<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo join(" ",$arr);
?>

<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo join(" ",$arr)."<br>";
echo join("+",$arr)."<br>";
echo join("-",$arr)."<br>"; 
echo join("X",$arr);
?>

<?php
echo lcfirst("Hello world!");
?>