簡體   English   中英

變量的三元運算符

[英]ternary operator for a variable

我有一個日期字段,其中的空值返回“ 1970-01-01”。 所以我想為變量$from創建一個三元運算符,仍然返回1970-01-01。我做錯了什么

$from=$asset_other_details->start_date;  //1970-01-01
$from == '1970-01-01' ? '' : $from ;

您必須根據如下比較輸出為$form分配新值:-

$from = $asset_other_details->start_date;  //1970-01-01
$from = ($from == '1970-01-01') ? '' : $from ;

輸出了解: -https : //eval.in/867743

您沒有從新值分配$from 請嘗試以下操作:

$from = ($asset_other_details->start_date == '1970-01-01') ? '' : $asset_other_details->start_date;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM