<?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. Jquery实现功能---购物车

    //需求,勾选选项时,总价格要跟着变,点击添加数量,总价格也要跟着变,全部要动态变化 //代码如下 <!DOCTYPE html> <html> <head> &l ...

  2. QEMU 运行uboot,动态加载内核与文件系统

    背景 上一讲我们完成了 编译 QEMU 以及简单地做了仿真.这一讲在 启动uboot 的基础上进行,以加强对于 运行地址,加载地址等理解. 有关资料: uboot 与 代码重定位 有这样的约定,ubo ...

  3. maze-----攻防世界

    题目下载之后在linux上查看一下 发现是elf文件尝试运行一下: 要求输入正确的flag才可以,ida查看 交叉引用 对长度和开头对比,进行判断. 转到400690查看 和#进行比较,hex 是一个 ...

  4. python基础学习(一)

    一,Python介绍 1,python的出生与应用 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆(中文名字:龟叔)为了在阿姆斯特丹打 ...

  5. 查看Python安装目录 -- 一个命令

    pip --version

  6. 最初步的.NET MvcApi + Vue 前后端分离IIS部署

    一.完成项目,各个项目部署在IIS上 1.前端项目部署     完成项目后在控制台npm run build 生成了dist文件夹 主要是部署这个文件夹 打开IIS  和部署AspNet MVC项目一 ...

  7. 项目上线后,遇到IE浏览器不显示大部分组件的问题

    document.addEventListener('touchmove',(evt)=>{ }) 以上是ES6 语法,箭头函数,当然在IE下是不行的啦. 所以改为:ES5语法 document ...

  8. JAVA String类常用方法

    一.String类String类在java.lang包中,java使用String类创建一个字符串变量,字符串变量属于对象.java把String类声明的final类,不能有类.String类对象创建 ...

  9. Django(十一)视图详解:基本使用、登录实例、HttpReqeust对象、HttpResponse对象

    一.视图(基于类的视图) [参考]https://docs.djangoproject.com/zh-hans/3.0/topics/class-based-views/intro/ 1)视图的功能 ...

  10. Windows安装tensorflow,配置vs2013,anaconda3.4,cudn9.0,cudnn7.0和pycharm

    前言 最近要开始学习深度,那么首先在电脑上安装tensorflow.但是我不知道是配置版本的问题,还是安装失误的问题,我安装了很久没有安装成功,最后重装了电脑,并且融合了所有的网上可以查到的方案才安装 ...