了解PHP代码

时间:2013-08-28 22:39:50

标签: php

我需要帮助尝试将此代码拆分为一种方式,以便我可以在每个true和false语句中添加更多代码。代码如下:

if(($modify?modify_event($event_id,"$year-$month-$day","$hour:$minute:00",$title,$desc):
            $event_id = create_event("$year-$month-$day","$hour:$minute:00",$username,$title,$desc))) 
        {

2 个答案:

答案 0 :(得分:1)

if ($modify) {
            $result = modify_event($event_id,"$year-$month-$day","$hour:$minute:00",$title,$desc);
}
else {
            $event_id = create_event("$year-$month-$day","$hour:$minute:00",$username,$title,$desc);
            $result = $event_id;
}
if ($result) {

答案 1 :(得分:0)

如果您的意思不止一个,那么:

if($modify){
  modify_event($event_id,"$year-$month-$day","$hour:$minute:00",$title,$desc);
  //more code here
}
else{
  $event_id = create_event("$year-$month-$day","$hour:$minute:00",$username,$title,$desc);
  //more code here
}