Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat does the following PHP code do (it mixes PHP and output)?
    primarykey
    data
    text
    <p>I am reading some WordPress plugin code, pardon my french, and even though I have coded a lot of stuff in anything from C to JavaScript, including PHP, I am not sure what kind of logic is accomplished with following:</p> <pre><code>&lt;?php function dcontact_options_page() { if($_GET['action'] == 'edit_group') { dcontact_action_edit_group(); return; } elseif($_GET['action'] == 'edit_form') { dcontact_action_form_settings(); return; } elseif(isset($_POST['set_order'])) { $result = dcontact_action_set_order(); } else if(isset($_POST['new_group'])) { $result = dcontact_action_new_group(); } else if($_GET['action'] == 'delete_group') { $result = dcontact_action_delete_group(); } if(!isset($result['message']) &amp;&amp; isset($_GET['message'])) $result['message'] = urldecode($_GET['message']) ?&gt; &lt;div class="wrap"&gt; &lt;div class="icon32" id="icon-options-general"&gt;&lt;br&gt;&lt;/div&gt; &lt;!-- More HTML AND PHP code blocks --&gt; &lt;!-- And then suddenly... --&gt; &lt;?php } /// What's this? End of function definition? PHP chokes on this with syntax error. ///... ?&gt; </code></pre> <p>I am no stranger to mixing PHP and verbatim output, and I also did my fair share of entering and exiting PHP blocks in the middle of say <code>if</code> statements, but this tops it. Can anyone explain what the guy was trying to accomplish? Does the code imply that if the <code>if</code> condition evaluates to <code>true</code> then whole lot of markup is written out (and more PHP is executed), <strong>but then</strong> the function definition ends, suddenly? Maybe it's what the function does? I mean, I would have used a <code>HEREDOC</code> syntax for readability.</p> <p>And to sum it up, my command line PHP 5.4.7 preprocessor chokes on the last <code>}</code>. And I can't say I blame it. Haven't seen spaghetti code like this in some time now.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload