<?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; 'Tarzan'";
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'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!");
?>

吴裕雄--天生自然 PHP开发学习:字符串变量的更多相关文章

  1. 吴裕雄--天生自然 JAVA开发学习:变量类型

    public class Variable{ static int allClicks=0; // 类变量 String str="hello world"; // 实例变量 pu ...

  2. 吴裕雄--天生自然 JAVASCRIPT开发学习:变量

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  3. 吴裕雄--天生自然 JAVASCRIPT开发学习: 变量提升

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  4. 吴裕雄--天生自然 JAVASCRIPT开发学习:运算符

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. 吴裕雄--天生自然 JAVA开发学习:String 类

    public class StringDemo{ public static void main(String args[]){ char[] helloArray = { 'r', 'u', 'n' ...

  6. 吴裕雄--天生自然 JAVASCRIPT开发学习:字符串

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  7. 吴裕雄--天生自然 PYTHON3开发学习:字符串

    var1 = 'Hello World!' var2 = "Runoob" #!/usr/bin/python3 var1 = 'Hello World!' var2 = &quo ...

  8. 吴裕雄--天生自然 PHP开发学习:echo 和 print 语句

    <?php echo "<h2>PHP 很有趣!</h2>"; echo "Hello world!<br>"; ec ...

  9. 吴裕雄--天生自然Android开发学习:1.2.1 使用Eclipse + ADT + SDK开发Android APP

    1.前言 这里我们有两条路可以选,直接使用封装好的用于开发Android的ADT Bundle,或者自己进行配置 因为谷歌已经放弃了ADT的更新,官网上也取消的下载链接,这里提供谷歌放弃更新前最新版本 ...

随机推荐

  1. Adapter之GridAdapter

    前言: 在我们写界面的时候想让我们展示的页面是网格的,这是我们可以使用GridAdapter,这个和listView的使用有相似之处,如果学过ListView的话还是很简单的 正文: 下面我们来看看G ...

  2. 初学微信小程序——配置问题(1)

    一.注册: 微信小程序账号注册:登录https://mp.weixin.qq.com  点击“立即注册”->”小程序” 注册完成后,下载微信小程序开发者工具: 依次点击:“首页”->“文档 ...

  3. Unbutu下装oracle

    Ubuntu 16.04安装Oracle 11gR2入门教程图文详解 转自         https://www.linuxidc.com/Linux/2017-12/149797.htm  原文作 ...

  4. python format使用方法

    #使用format 方法进行格式化 print("The number {1:} in hex is: {1:#x}, the number {0:} in oct is {0:o}&quo ...

  5. lucene实践 - 索引维护、多域查询、高亮显示

    之前的博客搜索栏用的是 sql 模糊查询进行查找,最近学完lucene,要学以致用啊,就把sql搜索给替换下来吧 中间遇到一些问题,也是学过程中没有提到的,所以说,还是实践出真知啊. lucene分开 ...

  6. hook框架frida添加至于安卓应用中

    转载至于https://koz.io/using-frida-on-android-without-root/ Frida is a great toolkit by @oleavr, used to ...

  7. Python最新暴力破解WiFi,攻破所有密码限制,最强破解!

    暴力破解wifi密码 这个代码也是非常简单,这里需要用Python中的pywifi这个库,所以需要在DOS命令下安装这个库,同样使用pip install pywifi,很简单就安装成功了,我用的是P ...

  8. php绕过open_basedir设置

    原理关于open_basedir    open_basedir是php.ini中的一个配置选项    它可将用户访问文件的活动范围限制在指定的区域,    假设open_basedir=/home/ ...

  9. 软件管理-RPM命令管理:安装升级与卸载

    1.包名与包全名 包名 : 操作已经安装的软件包时,使用包名:系统会搜索var/lib/rpm中的数据库 包全名: 操作的包时没有安装的软件包时,使用包全名,而且注意路径 2.RPM安装 切换到光盘p ...

  10. c#实现"扫描检测硬件改动"

    public static class Win32Api { public const int CM_LOCATE_DEVNODE_NORMAL = 0x00000000; public const ...