您现于de位置乃:亚博 > APP基础

亚博 2017-12-10 APP基础 2913

APP中"{}"大括号de用法总结

1 {} 表示程序块de开始和结束

if ($x==$y) 
{ 
 do_nothing(); 
}


2 {}用来表示字符串下标

(引用longnetpro兄弟de话)
$s{1}表示字符串

$sde第2个字节(不乃第1个)

基本等同于$s[1] 只不过后者乃老de写法

APP技巧推荐第1种写法


3 分离变量

$s = "Di, "; 
echo ("${s}omething"); 
//Output: Di, omething

而如果用echo ("$something");
那么就会输出 $something 这个变量. 


更多示例


示例1

$var='sky';
echo "{$var}boy";
//输出:skyboy


示例2

$my_str="1234";
$my_str{2}='5';
echo $my_str;


评论

  • 2019-08-24

    Hello, I enjoy reading all of your article. I like to write a little comment to support you.

    回复
  • 2019-08-21

    I just like the helpful info you supply for your articles. I'll bookmark your weblog and take a look at once more here frequently. I'm somewhat certain I'll be told plenty of new stuff right right here! Good luck for the next!

    回复
  • 2019-08-19

    Hi there, You've done a fantastic job. I will certainly digg it and personally suggest to my friends. I'm confident they'll be benefited from this site.

    回复
  • 2019-08-19

    Excellent blog you have here but I was curious if you knew of any forums that cover the same topics talked about here? I'd really love to be a part of online community where I can get responses from other experienced people that share the same interest. If you have any recommendations, please let me know. Thanks a lot!

    回复
  • 2019-08-18

    Yes! Finally something about balms protect.

    回复