在php7中,千万不要把你的??当成三元运算符使用!!!

  1. <?php
  2. $tmparr = ['cover'=>'http://img.kevinfei.com.cn'];
  3. echo isset($tmparr['cover'])."\n";
  4. echo !empty($tmparr['cover'])."\n";
  5. $rep = isset($tmparr['cover']) && !empty($tmparr['cover']) ? $tmparr['cover'] : '';
  6. var_dump($rep);
  7. $result = isset($tmparr['cover']) && !empty($tmparr['cover']) ?? '';
  8. var_dump($result);
  9. // 1
  10. // 1
  11. // string(24) "http://img.kevinfei.com.cn"
  12. // bool(true)
  13. ?>

php7新增一个运算符??,不知道大家平时是在什么时候用它,但是我一直用它代替以前的三元运算符? :,今天偶然发现,它和三元运算符是不一样的,.

在想用??判断一个赋值为0的变量的时候要小心了,结果可能和想象中的不一样

从上面的结果可以看出,在php7中 ?? 代表isset ?: 代表empty

今天想告诉大家在php7中关于这个几个最常用的内置函数而可能会引发的问题,需要注意一下啊!!!

点赞 ( 1 )

24 条评论

  1. Konya Havacılık Sigortası

    Keep on working, great job!

  2. BahisDurağı

    BahisDurağı web sitesinde bahis tutkunları için en doğru kaynaklar yer alır. Bahis oyuncularına rehberlik eden sitede bahis opsiyonları, güncel bahis seçenekleri, maç analizlerinin yer aldığı siteler hakkında bilgiler mevcut.

  3. BahisKrallığı

    İnternetteki bahis siteleri hakkındaki en önemli detaylardan biri de güvenlik özellikleridir. Güvenli bahis platformları hakkında bilgileri arayan kullanıcılar için BahisKrallığı sitemizdeki paylaşımlar öne çıkıyor.

  4. It's actually a great and useful piece of info. I'm satisfied that you simply shared this useful information with us. Please keep us up to date like this. Thanks for sharing.

  5. takip

    What's Taking place i'm new to this, I stumbled upon this I've discovered It absolutely helpful and it has helped me out loads. I hope to contribute & assist other users like its helped me. Great job.

  6. link-analysis

    I have read some excellent stuff here. Definitely value bookmarking for revisiting. I wonder how so much effort you put to make the sort of great informative web site.

  7. go website

    I am truly delighted to read this website posts which consists of plenty of useful data, thanks for providing these kinds of statistics.

  8. visit website

    Excellent site. Plenty of helpful information here. I am sending it to several buddies ans additionally sharing in delicious. And of course, thank you in your effort!

  9. visitwebsite

    I don't even know how I finished up here, however I assumed this publish was great. I don't realize who you are but certainly you are going to a well-known blogger if you happen to aren't already. Cheers!

  10. visit webpage

    Wow, this paragraph is pleasant, my sister is analyzing such things, thus I am going to convey her.

  11. Visit websiteizlenme

    This paragraph provides clear idea in support of the new viewers of blogging, that actually how to do blogging and site-building.

  12. Aylık beğeni satın al

    Fenomega ile instagram aylık beğeni satın almak ve tüm paylaşımlarınıza yada belirtilen sayıdaki paylaşımlarınız için özel https://cutt.ly/QSWJRyg aylık beğeni satın al

  13. instagram takipçi al

    Right now it seems like Movable Type is the preferred blogging platform available right now. (from what I've read) Is that what you are using on your blog?

  14. wisit takip site

    I believe that is one of the so much significant information for me. And i am glad reading your article. But should remark on few basic issues, The website taste is ideal, the articles is really nice : D. Just right task, cheers

  15. t.co

    Your style is so unique compared to other people I've read stuff from. Many thanks for posting when you have the opportunity, Guess I will just bookmark this blog.

  16. bit.ly

    I am in fact happy to glance at this website posts which includes tons of useful information, thanks for providing these kinds of data.

  17. fly cheap

    Very descriptive post, I enjoyed that a lot. Will there be a part 2?

  18. cheapest airfare possible

    What's up to all, how is all, I think every one is getting more from this web page, and your views are good for new viewers.

  19. how to get cheap flights

    Yes! Finally something about cheap flights.

  20. flight search

    Hi there, just became aware of your blog through Google, and found that it is really informative. I'm going to watch out for brussels. I'll be grateful if you continue this in future. Many people will be benefited from your writing. Cheers!

  21. booking flights

    I feel this is one of the so much vital information for me. And i am happy reading your article. However wanna remark on few basic things, The web site style is ideal, the articles is truly excellent : D. Excellent activity, cheers

  22. lowest airfares possible

    you are truly a good webmaster. The website loading pace is amazing. It sort of feels that you are doing any distinctive trick. Moreover, The contents are masterpiece. you have done a magnificent job on this topic!

  23. Alba

    Hey There. I found your weblog the use of msn. This is an extremely smartly written article. I'll make sure to bookmark it and return to learn extra of your helpful information. Thanks for the post. I'll definitely comeback.

  24. gamefly

    I like the valuable info you provide in your articles. I will bookmark your blog and check again here regularly. I'm quite certain I'll learn many new stuff right here! Best of luck for the next!

发表评论

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

插入图片
s
返回顶部