2016-09-20 40 views
0

我有3個變量墊,跟隨,不僅 一個可以在一個時間值我想要什麼,如果任何變量具有價值應該在味精獲取數據,如果值設置

此更新是我的邏輯

<?php  
    $mat = $this->input->post('mater_mesaage') ; 
    $folow = $this->input->post('follow_message') ; 
    $not = $this->input->post('not_inst_comment') ;  
    if (isset($mat)){ 
     echo "Mat"; 
     $msg = $mat ; 
    } 
    if (isset($folow)) { 
     echo "folow" ; 
     $msg = $folow ; 
    } 
    if (isset($not)){ 
     echo "not" ; 
     $msg = $not ; 
    } 
    echo $msg ; 
?> 
+0

** == **用於比較時,必須使用** = **用於分配一個值 – Sunny

+0

還是它不工作 –

回答

1

請在時間=

<?php  
    $mat = $this->input->post('mater_mesaage') ; 
    $folow = $this->input->post('follow_message') ; 
    $not = $this->input->post('not_inst_comment') ;  
    if (isset($mat)){ 
     echo "Mat" ; 
     $msg = $mat ; 
    } 
    if (isset($folow)) { 
     echo "folow" ; 
     $msg = $folow ; 
    } 
    if (isset($not)){ 
     echo "not" ; 
     $msg = $not ; 
    } 
    echo $msg ; 
?> 
0

一個值替換==所以ü應有權使用elseif所以在這裏你去:

<?php  
    $mat = $this->input->post('mater_mesaage') ; 
    $folow = $this->input->post('follow_message') ; 
    $not = $this->input->post('not_inst_comment') ;  
    if (isset($mat)){ 
     echo "Mat"; 
     $msg == $mat; 
    }elseif (isset($folow)) { 
     echo "folow"; 
     $msg == $folow; 
    }else{ 
     echo "not"; 
     $msg == $not; 
    } 
    echo $msg; 
?> 
0
<?php  
    $mat = $this->input->post('mater_mesaage'); 
    $folow = $this->input->post('follow_message'); 
    $not = $this->input->post('not_inst_comment');  
    if ($mat != '' || $folow != '' || $not != '') { 
     $msg = ($mat != '') ? $mat : (($folow != '') ? $follow : $not); 
    } 
?> 
+0

這裏的問題是,如果$墊有價值,它將被打印,但如果$ follow或$沒有價值,它不打印 您的代碼也有同樣的問題 –

相關問題