<?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. 本地连接 HDFS 报错 Exception in thread "main" org.apache.hadoop.security.AccessControlException: org.apache.hadoop.security.AccessControlException: Permission denied: user=JM.H,access=WRITE, inode="":r

    此时 到hdfs机器下修改hdfs-site.xml即可 添加如下配置 <property> <name>dfs.permissions</name> <va ...

  2. loadrunner11完整卸载

    1.在控制面板中卸载掉loadrunner11的程序 2.删除loadrunner11安装目录 3.删除C盘(和安装目录下)   wlrun.*和vugen.* 4.删除回收站 5.清除注册表(运行r ...

  3. 利用uboot下载引导Kernel(TFTP)以及挂载网络Rootfs(NFS)

    背景: 在嵌入式开发中,经常需要对系统的各个部分进行修改.倘若每次修改都烧写到板子中,一来浪费时间,其次影响存储介质寿命. 所以,需要一些手段来避免此类问题. 概览: 编译uboot 将uboot写入 ...

  4. Tensorflow官方文档 input_data.py 下载

    说明: 本篇文章适用于MNIST教程下载数据集. # Copyright 2015 Google Inc. All Rights Reserved. # # Licensed under the Ap ...

  5. brew services start redis 无法使用问题排查

    起因 Mac上使用brew services start --all指令同时启动多个服务显示成功 但是,连接四个服务所在端口均无响应. 仔细核对过brew指令启动服务使用的路径.配置文件路径均无问题. ...

  6. wpf和winform的区别

    深入浅出WPF(7)——数据的绿色通道,Binding(上) 水之真谛关注6人评论28117人阅读2008-06-23 02:40:00  http://liuteimeng.blog.51cto.c ...

  7. 7.8 Varnish 其他命令

  8. LeetCode1005 K次取反后最大化的数组和(贪心+Java简单排序)

    题目: 给定一个整数数组 A,我们只能用以下方法修改该数组:我们选择某个个索引 i 并将 A[i] 替换为 -A[i],然后总共重复这个过程 K 次.(我们可以多次选择同一个索引 i.) 以这种方式修 ...

  9. leetcode(数据结构)—— 镜像二叉树

    镜像二叉树,力扣上面的的题目,这道题很简单,放出来的原因是它要求用两种解法来写这道题——递归和迭代,而且数据结构学到了树,记录自己学习的过程,以免忘了,没地方找. 题目的意图很明显,就是然你写个程序看 ...

  10. Web安全测试学习笔记 - vulhub环境搭建

    Vulhub和DVWA一样,也是开源漏洞靶场,地址:https://github.com/vulhub/vulhub 环境搭建过程如下: 1. 下载和安装Ubuntu 16.04镜像,镜像地址:htt ...