关于php的0,'',false,null引发的空字符串和空格的空字符串的思考

关于php的0,空字符串,false,null引发的空字符串和空格的空字符串的思考,今天在业务开发中遇到一个有点意思的问题,在仔细思考下发现了很有意思的点,接下来出题

  1. <?php
  2. $a = "";
  3. $b = " ";
  4. $c=trim($b);
  5. if($a==$b){
  6. var_dump('===');
  7. }else{
  8. var_dump("!=");
  9. }
  10. echo '<br>';
  11. if($a==$c){
  12. var_dump('===');
  13. }else{
  14. var_dump("!=");
  15. }
  16. ?>

以上为实例,不知道大家在初次遇到这个问题会怎么处理,是否会先入为主,而导致你业务出错,浪费宝贵时间。
以下为输出结果
eg:

  1. string(2) "!="
  2. string(3) "==="

我在没有仔细考虑这个问题的时候,一直认为,””、” “的区别,在肉眼上看,这个2个好像都是空字符串,可代码会告诉你,不,他们不一样,但是一定等你仔细看的时候,你一定就会发现,其中一个是因为多了一个空格,而在计算机的时间里,空格也是占用内存空间的,自然在语言处理中,也会进行区别对待。

所以任何事情都不能想当然,眼见不一定为实,一定要多思考,和实践。以下引用一下伟大领袖毛主席的话。

实践才是检验真理的唯一标准—-毛泽东

点赞 ( 0 )

34 条评论

  1. takipçi satın al

    Helpful info. Fortunate me I found your site by chance, and I am stunned why this coincidence did not happened in advance! I bookmarked it.

  2. instagram takipçi arttirma türk

    Wow that was unusual. I just wrote an really long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Anyways, just wanted to say great blog!

  3. instagram takipçi satın al

    Hey are using Wordpress for your site platform? I'm new to the blog world but I'm trying to get started and set up my own. Do you require any coding knowledge to make your own blog? Any help would be greatly appreciated!

  4. takipçi satın al

    Nice response in return of this issue with solid arguments and telling all regarding that.

  5. wso shell download

    Someone necessarily assist to make severely articles I might state. That is the very first time I frequented your website page and thus far? I amazed with the research you made to make this particular post extraordinary. Wonderful job!

  6. объяснение

    Bloomberg узнал детали данных разведки США о подготовке России к атаке на Украину объяснение

  7. more about the author

    Игры – новости и статьи по тегу more about the author

  8. takipçi almaK

    I don't even know how I ended up here, but I thought this post was good. I do not know who you are but certainly you are going to a famous blogger if you are not already ;) Cheers!

  9. satın al takipçi

    Why users still make use of to read news papers when in this technological globe all is available on web?

  10. Wso php download

    Wow, amazing blog format! How long have you ever been blogging for? you make running a blog glance easy. The overall look of your website is great, let alone the content!

  11. youtube izlenme

    I constantly spent my half an hour to read this weblog's posts every day along with a cup of coffee.

  12. youtube abone

    Thanks for every other informative website. The place else may I get that type of information written in such an ideal method? I've a project that I am simply now working on, and I have been at the look out for such information.

  13. instagram takipci

    If you desire to increase your knowledge simply keep visiting this web page and be updated with the most recent information posted here.

  14. instagram takipçi al

    Thank you for sharing your info. I really appreciate your efforts and I am waiting for your next write ups thanks once again.

  15. takipçi alma

    Howdy! This post couldn't be written much better! Looking at this post reminds me of my previous roommate! He constantly kept talking about this. I'll send this article to him. Fairly certain he will have a very good read. Thank you for sharing!

  16. paypal hesabı nasıl açılır

    What's up it's me, I am also visiting this web page regularly, this site is truly pleasant and the people are really sharing fastidious thoughts.

  17. Ucuz instagram takipçi satın al

    Quality articles is the secret to be a focus for the viewers to pay a visit the web site, that's what this website is providing.

  18. instagram takipci satin alma

    Hey there! Do you know if they make any plugins to assist with Search Engine Optimization? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good success. If you know of any please share. Thanks!

  19. havadis yaşam

    Spot on with this write-up, I really feel this web site needs a great deal more attention. I'll probably be returning to read through more, thanks for the advice!

  20. instagram takipçi satın al

    Hey! This is my first comment here so I just wanted to give a quick shout out and say I really enjoy reading through your posts. Can you recommend any other blogs/websites/forums that deal with the same subjects? Thank you so much!

  21. free followers

    I am regular visitor, how are you everybody? This piece of writing posted at this website is genuinely fastidious.

  22. Excellent way of explaining, and fastidious article to get facts about my presentation topic, which i am going to convey in institution of higher education.

  23. instagram takipçi

    magnificent issues altogether, you just won a brand new reader. What could you suggest about your publish that you simply made a few days in the past? Any sure?

  24. elektroniksigara

    I would like to thank you for the efforts you have put in penning this blog. I really hope to see the same high-grade content from you in the future as well. In fact, your creative writing abilities has motivated me to get my own website now ;)

  25. teknoloji haberleri

    Great article, totally what I was looking for.

  26. Adsmister

    Good answer back in return of this issue with genuine arguments and describing all about that.

  27. Bocaidama

    Magnificent beat ! I wish to apprentice while you amend your site, how could i subscribe for a weblog website? The account aided me a appropriate deal. I have been a little bit familiar of this your broadcast provided vibrant clear concept

  28. Domingo

    Actually when someone doesn't know after that its up to other people that they will help, so here it happens.

  29. Konya Eczane Sigortası

    Fantastic beat ! I wish to apprentice while you amend your website, how can i subscribe for a blog web site? The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear idea

  30. I’m not that much of a online reader to be honest but your sites really nice, keep it up! I'll go ahead and bookmark your website to come back down the road. Cheers

  31. Zack

    Good post. I certainly appreciate this site. Keep it up!

  32. wisit web site takip

    I was suggested this website by my cousin. I'm not sure whether this post is written by him as no one else know such detailed about my problem. You're wonderful! Thanks!

  33. AmssmDwenueKes

    ivermectin 0.5% lotion ivermectin lotion for scabies

  34. RaymondNox

    https://buylipitor.store/# cheap lipitor 20 mg

发表评论

人生在世,错别字在所难免,无需纠正。

插入图片
s
返回顶部