pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <tfoot id='PsyoK'></tfoot>

    <small id='PsyoK'></small><noframes id='PsyoK'>

    <legend id='PsyoK'><style id='PsyoK'><dir id='PsyoK'><q id='PsyoK'></q></dir></style></legend>
        <bdo id='PsyoK'></bdo><ul id='PsyoK'></ul>
    1. <i id='PsyoK'><tr id='PsyoK'><dt id='PsyoK'><q id='PsyoK'><span id='PsyoK'><b id='PsyoK'><form id='PsyoK'><ins id='PsyoK'></ins><ul id='PsyoK'></ul><sub id='PsyoK'></sub></form><legend id='PsyoK'></legend><bdo id='PsyoK'><pre id='PsyoK'><center id='PsyoK'></center></pre></bdo></b><th id='PsyoK'></th></span></q></dt></tr></i><div class="hvezf3g" id='PsyoK'><tfoot id='PsyoK'></tfoot><dl id='PsyoK'><fieldset id='PsyoK'></fieldset></dl></div>

        PHP 錯誤:未加括號的 `a ?乙:丙?d : e` 已棄用.使用

        PHP Error : Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`(PHP 錯誤:未加括號的 `a ?乙:丙?d : e` 已棄用.使用`(a ? b : c) ?d : e` 還是 `a ?b : (c ? d : e)`) - IT屋-程

        • <bdo id='l3Iu5'></bdo><ul id='l3Iu5'></ul>

          <small id='l3Iu5'></small><noframes id='l3Iu5'>

                  <tbody id='l3Iu5'></tbody>
                <legend id='l3Iu5'><style id='l3Iu5'><dir id='l3Iu5'><q id='l3Iu5'></q></dir></style></legend>
              1. <tfoot id='l3Iu5'></tfoot>

                <i id='l3Iu5'><tr id='l3Iu5'><dt id='l3Iu5'><q id='l3Iu5'><span id='l3Iu5'><b id='l3Iu5'><form id='l3Iu5'><ins id='l3Iu5'></ins><ul id='l3Iu5'></ul><sub id='l3Iu5'></sub></form><legend id='l3Iu5'></legend><bdo id='l3Iu5'><pre id='l3Iu5'><center id='l3Iu5'></center></pre></bdo></b><th id='l3Iu5'></th></span></q></dt></tr></i><div class="askmlyo" id='l3Iu5'><tfoot id='l3Iu5'></tfoot><dl id='l3Iu5'><fieldset id='l3Iu5'></fieldset></dl></div>

                  本文介紹了PHP 錯誤:未加括號的 `a ?乙:丙?d : e` 已棄用.使用`(a ? b : c) ?d : e` 還是 `a ?b : (c ? d : e)`的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在將 PHP 7.4 用于 Laravel 應用程序,并且我經常收到此異常.

                  ErrorException (E_DEPRECATED)無括號的`a ?乙:丙?d : e` 已棄用.使用`(a ? b : c) ?d : e` 還是 `a ?b : (c ? d : e)`

                  觸發這個異常的代碼是:

                  foreach ($allLanguages as $languageKey) {$original[$languageKey] =isset($values[$languageKey])?$values[$languageKey]: isset($filesContent[$fileName][$languageKey][$key]) ?$filesContent[$fileName][$languageKey][$key] : '';}

                  有人能幫我解決這個問題嗎?

                  發現這是由于 PHP 中的某些升級導致的 E_DEPRECATED 錯誤,但是有什么方法可以通過將不推薦使用的代碼轉換為最新代碼來解決此異常?

                  解決方案

                  在 php 中進行了此更改以消除決策樹中的歧義,以便有明確的條件執行順序.

                  棄用警告在此處轉載:

                  代碼:

                  $allLanguages = ['en', 'es', 'fr'];$values = ['es' =>'西班牙語1'];$文件內容 = ['富' =>['es' =>['酒吧' =>'西班牙語2'],'fr' =>['酒吧' =>'法語']]];$文件名 = 'foo';$key = 'bar';$原始 = [];foreach ($allLanguages as $languageKey) {$original[$languageKey] =isset($values[$languageKey])?$values[$languageKey]: isset($filesContent[$fileName][$languageKey][$key])?$filesContent[$fileName][$languageKey][$key]: '';}var_export($original);

                  輸出:

                  <塊引用>

                  已棄用:未加括號的 `a ?乙:丙?d : e` 已棄用.使用`(a ? b : c) ?d : e` 還是 `a ?b : (c ? d : e)` 在第 17 行的/in/TG4g2

                  數組 ('en' =>'','es' =>'西班牙語2','fr' =>'法語',)

                  作為腳本的人類讀者,我會假設從左到右讀取您的條件——但這會將 Spanish1 作為輸出值.

                  即使在 php7.4 之前,輸出也是Spanish2,因為后者在決策樹中的分叉被優先考慮.

                  為避免這種情況,您必須將條件括在括號中,以準確說明應如何處理執行順序.

                  另外,我同意@Laurel 的觀點,在 php7 中是時候讓您接受空合并運算符的句法甜蜜了.這將避免優先級問題和使用括號的需要,但根據您想要的結果,您可能需要對條件重新排序.

                  優先于$values:(Demo)

                  $original[$languageKey] =$values[$languageKey]??$filesContent[$fileName][$languageKey][$key]??'';

                  優先于$filesContent:(Demo)

                  $original[$languageKey] =$filesContent[$fileName][$languageKey][$key]??$values[$languageKey]??'';

                  附言IIRC,php 手冊建議不要在代碼清晰的基礎上使用這樣的嵌套三元組/條件.我不介意這種情況,我喜歡避免代碼膨脹,但其他開發人員可能會采取更純粹的立場.

                  I am using PHP 7.4 for a laravel application and I am getting this exception very frequently.

                  ErrorException (E_DEPRECATED)
                  Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`
                  

                  The code which triggers this exception is :

                  foreach ($allLanguages as $languageKey) {
                      $original[$languageKey] =
                          isset($values[$languageKey])
                              ? $values[$languageKey]
                              : isset($filesContent[$fileName][$languageKey][$key]) ? $filesContent[$fileName][$languageKey][$key] : '';
                  }
                  

                  Can any help me to resolve this issue?

                  Found that this is E_DEPRECATED error due to some upgrade in PHP, but is there any way to resolve this exception by converting the deprecated code to latest?

                  解決方案

                  This change in php has been done to remove ambiguity in the decision tree so that there is an explicit order of condition execution.

                  The deprecation warning is reproduced here:

                  Code:

                  $allLanguages = ['en', 'es', 'fr'];
                  $values = ['es' => 'Spanish1'];
                  $filesContent = [
                      'foo' => [
                          'es' => ['bar' => 'Spanish2'],
                          'fr' => ['bar' => 'French']
                      ]
                  ];
                  $fileName = 'foo';
                  $key = 'bar';
                  
                  $original = [];
                  foreach ($allLanguages as $languageKey) {
                      $original[$languageKey] =
                          isset($values[$languageKey])
                              ? $values[$languageKey]
                              : isset($filesContent[$fileName][$languageKey][$key])
                                  ? $filesContent[$fileName][$languageKey][$key]
                                  : '';
                  }
                  var_export($original);
                  

                  Output:

                  Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/TG4g2 on line 17
                  

                  array (
                    'en' => '',
                    'es' => 'Spanish2',
                    'fr' => 'French',
                  )
                  

                  As a human-reader of your script, I would assume the reading of your condition as left to right -- but this would place Spanish1 as the output value.

                  Even before php7.4, the output isSpanish2 because the latter fork in the decision tree is given precedence.

                  To avoid this, you must wrap your conditions in parentheses to dictate exactly how the order of execution should be handled.

                  Also, I agree with @Laurel that in php7 it is time for you to embrace the syntactic sugary sweetness that is the null coalescing operator. This will avoid precedence issues and the need to use parentheses, but depending on your desired results, you may need to reorder your conditions.

                  Priority to $values: (Demo)

                  $original[$languageKey] =
                      $values[$languageKey]
                          ?? $filesContent[$fileName][$languageKey][$key]
                              ?? '';
                  

                  Priority to $filesContent: (Demo)

                  $original[$languageKey] =
                      $filesContent[$fileName][$languageKey][$key]
                          ?? $values[$languageKey]
                              ?? '';
                  

                  P.s. IIRC, the php manual advises against the use of nested ternaries/conditionals like this on the basis of code clarity. I don't mind this scenario and I like the avoidance of code bloat, but other devs may take a more purist stance.

                  這篇關于PHP 錯誤:未加括號的 `a ?乙:丙?d : e` 已棄用.使用`(a ? b : c) ?d : e` 還是 `a ?b : (c ? d : e)`的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)
                  • <bdo id='UhMAl'></bdo><ul id='UhMAl'></ul>

                      <small id='UhMAl'></small><noframes id='UhMAl'>

                          <tbody id='UhMAl'></tbody>

                        <legend id='UhMAl'><style id='UhMAl'><dir id='UhMAl'><q id='UhMAl'></q></dir></style></legend>
                        <i id='UhMAl'><tr id='UhMAl'><dt id='UhMAl'><q id='UhMAl'><span id='UhMAl'><b id='UhMAl'><form id='UhMAl'><ins id='UhMAl'></ins><ul id='UhMAl'></ul><sub id='UhMAl'></sub></form><legend id='UhMAl'></legend><bdo id='UhMAl'><pre id='UhMAl'><center id='UhMAl'></center></pre></bdo></b><th id='UhMAl'></th></span></q></dt></tr></i><div class="xah73xr" id='UhMAl'><tfoot id='UhMAl'></tfoot><dl id='UhMAl'><fieldset id='UhMAl'></fieldset></dl></div>
                        <tfoot id='UhMAl'></tfoot>
                          1. 主站蜘蛛池模板: 实木家具_实木家具定制_全屋定制_美式家具_圣蒂斯堡官网 | 智能交通网_智能交通系统_ITS_交通监控_卫星导航_智能交通行业 | 淄博不锈钢,淄博不锈钢管,淄博不锈钢板-山东振远合金科技有限公司 | 免费网站网址收录网_海企优网站推荐平台 | 氨水-液氨-工业氨水-氨水生产厂家-辽宁顺程化工 | 湖南教师资格网-湖南教师资格证考试网 | 防伪溯源|防窜货|微信二维码营销|兆信_行业内领先的防伪防窜货数字化营销解决方案供应商 | 国际线缆连接网 - 连接器_线缆线束加工行业门户网站 | 天津试验仪器-电液伺服万能材料试验机,恒温恒湿标准养护箱,水泥恒应力压力试验机-天津鑫高伟业科技有限公司 | 颚式破碎机,圆锥破碎机,制砂机-新乡市德诚机电制造有限公司 | 地脚螺栓_材质_标准-永年县德联地脚螺栓厂家 | 滚筒烘干机_转筒烘干机_滚筒干燥机_转筒干燥机_回转烘干机_回转干燥机-设备生产厂家 | 智慧钢琴-电钢琴-便携钢琴-数码钢琴-深圳市特伦斯乐器有限公司 | 纯化水设备-纯水设备-超纯水设备-[大鹏水处理]纯水设备一站式服务商-东莞市大鹏水处理科技有限公司 | 精密钢管,冷拔精密无缝钢管,精密钢管厂,精密钢管制造厂家,精密钢管生产厂家,山东精密钢管厂家 | 南京种植牙医院【官方挂号】_南京治疗种植牙医院那个好_南京看种植牙哪里好_南京茀莱堡口腔医院 尼龙PA610树脂,尼龙PA612树脂,尼龙PA1010树脂,透明尼龙-谷骐科技【官网】 | 网站优化公司_北京网站优化_抖音短视频代运营_抖音关键词seo优化排名-通则达网络 | 长城人品牌官网| 国标白水泥,高标号白水泥,白水泥厂家-淄博华雪建材有限公司 | 气动隔膜泵-电动隔膜泵-循环热水泵-液下排污/螺杆/管道/化工泵「厂家」浙江绿邦 | 石家庄律师_石家庄刑事辩护律师_石家庄取保候审-河北万垚律师事务所 | 视觉检测设备_自动化检测设备_CCD视觉检测机_外观缺陷检测-瑞智光电 | 无线遥控更衣吊篮_IC卡更衣吊篮_电动更衣吊篮配件_煤矿更衣吊篮-力得电子 | 生物颗粒燃烧机-生物质燃烧机-热风炉-生物颗粒蒸汽发生器-丽水市久凯能源设备有限公司 | 焊接烟尘净化器__焊烟除尘设备_打磨工作台_喷漆废气治理设备 -催化燃烧设备 _天津路博蓝天环保科技有限公司 | 户外健身路径_小区健身器材_室外健身器材厂家_价格-浩然体育 | 胶水,胶粘剂,AB胶,环氧胶,UV胶水,高温胶,快干胶,密封胶,结构胶,电子胶,厌氧胶,高温胶水,电子胶水-东莞聚力-聚厉胶粘 | 清水混凝土修复_混凝土色差修复剂_混凝土色差调整剂_清水混凝土色差修复_河南天工 | 酶联免疫分析仪-多管旋涡混合仪|混合器-莱普特科学仪器(北京)有限公司 | 塑料撕碎机_编织袋撕碎机_废纸撕碎机_生活垃圾撕碎机_废铁破碎机_河南鑫世昌机械制造有限公司 | 气动隔膜阀_气动隔膜阀厂家_卫生级隔膜阀价格_浙江浙控阀门有限公司 | 北京三友信电子科技有限公司-ETC高速自动栏杆机|ETC机柜|激光车辆轮廓测量仪|嵌入式车道控制器 | 外贸网站建设-外贸网站设计制作开发公司-外贸独立站建设【企术】 | 济南网站策划设计_自适应网站制作_H5企业网站搭建_济南外贸网站制作公司_锐尚 | 微学堂-电动能源汽车评测_电动车性能分享网| 招商帮-一站式网络营销服务|搜索营销推广|信息流推广|短视视频营销推广|互联网整合营销|网络推广代运营|招商帮企业招商好帮手 | 除尘布袋_液体过滤袋_针刺毡滤料-杭州辉龙过滤技术有限公司 | 硬度计,金相磨抛机_厂家-莱州华煜众信试验仪器有限公司 | 车充外壳,车载充电器外壳,车载点烟器外壳,点烟器连接头,旅行充充电器外壳,手机充电器外壳,深圳市华科达塑胶五金有限公司 | 重庆磨床过滤机,重庆纸带过滤机,机床伸缩钣金,重庆机床钣金护罩-重庆达鸿兴精密机械制造有限公司 | 安平县鑫川金属丝网制品有限公司,防风抑尘网,单峰防风抑尘,不锈钢防风抑尘网,铝板防风抑尘网,镀铝锌防风抑尘网 |