php - Why does adding if(strlen($content)): create a syntax error with an unexpected '}'? -


i don't see missing opening curly brace or not enough curly braces , yet when fine until added if(strlen($content)): $form = etcetera below. see of code commented out trying isolate bug, can't understand why throws parse error. don't see missing curly brace or curly brace.

function ssp_survey_shortcode($args, $content='') {      // setup our return variable     $output = '';      try {          // begin building our output html         $output = '<div class="ssp ssp-survey">';          // survey id         $survey_id = (isset($args['id'])) ?(int)$args['id'] : 0;          // survey object         $survey = get_post($survey_id);          // if survey not valid ssp_survey post, return message         if(!$survey_id || $survey->post_type !== 'ssp_survey'):          $output.= '<p>the requested survey not exist.</p>';          else:          // build form html         $form = '';          if(strlen($content)):             $form = '<div class="ssp-survey-content">'.wpautop($content).'</div>';          endif;          $submit_button = '';          if(!ssp_question_is_answered($survey_id)):             $submit_button = '<div class="ssp-survey-footer">             <p class="ssp-input-container ssp-submit">                 <input type="submit" name="ssp_submit" value="submit response" />             </p>             </div>';         $form.= '<form id="survey_'.$survey_id.'" class="ssp-survey-form">'.ssp_get_question_html($survey_id).$submit_button.'</form>';         // append form html $output         $output.=$form;          endif;          /*// close out output html div         $output.= '</div>';*/      } catch(exception $e) {          // php error     }      /*// return output     return $output;*/  } 

look missing endif; in code.

tip, syntax if():endif; best used in template files, php code used if(){} sintax.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -