如何在带括号的php中使用单引号和双引号?

时间:2016-11-28 12:21:57

标签: php html

我在使用带有括号的单引号和双引号时遇到问题

我有任何错误,如果条件请任何一个帮助

 $resonjob['Post_type']='Jobs';
    $resonjob['reason']='reasonstatus.php?job_id='.$row['job_id'];
    $nestedData[] = '<select onchange="reasonstatus(this.value)" style="width:80px;">
    <option value="'.$resonjob['reason'].'&type='.$resonjob['Post_type'].'&status=1" '.if($row['status']=='1'){.' selected;'.}.'>Active</option>
    <option value="'.$resonjob['reason'].'&type='.$resonjob['Post_type'].'&status=2" '.if($row['status']=='2'){.' selected;'.}.' >Inactive</option>
    </select>';

1 个答案:

答案 0 :(得分:0)

<?php
$resonjob['Post_type']='Jobs';
    $resonjob['reason']='reasonstatus.php?job_id='.$row['job_id'];
    $nestedData[] = '<select onchange="reasonstatus(this.value)" style="width:80px;">
    <option value="'.$resonjob['reason'].'&type='.$resonjob['Post_type'].'&status=1" '.($row['status']=='1' ? 'selected' : '').'>Active</option>
    <option value="'.$resonjob['reason'].'&type='.$resonjob['Post_type'].'&status=2" '.($row['status']=='2' ? ' selected' : '').' >Inactive</option>
    </select>';