How would I go about commenting all of this code when it has breaks in the php sections... If I wrap /**/ around it, it doesn't work.
Obviously I can make it work by not being lazy but if i want to be lazy... does anyone know how you might comment this whole block?
if($fields){
?>
<ul>
<?php
foreach($fields as $field){
?>
<li>
<?php
/*if($field['label']){
echo $field['label'];
}*/
print_ext($field);
?>
</li>
<?php
}
?>
</ul>
<?php
}
The following solution should work. You might have issues if you are wrapping the comments that exist already around if($field['label']) so I have deleted them as shown below.
<?php
/*
if($fields){
?>
<ul>
<?php
foreach($fields as $field){
?>
<li>
<?php
if($field['label']){
echo $field['label'];
}
print_ext($field);
?>
</li>
<?php
}
?>
</ul>
<?php
}
*/
?>
For more information look at this answer.
You can't. You should just avoid coding like that altogether as it creates a horribly unreadable mess.
You can't really but you can turn it off pretty easily.
if($fields && false){
?>
<ul>
<?php
foreach($fields as $field){
?>
<li>
<?php
/*if($field['label']){
echo $field['label'];
}*/
print_ext($field);
?>
</li>
<?php
}
?>
</ul>
<?php
}
Not really commenting, but you can disable this block like this (almost no matter its content):
<?php $bar = <<<'EOD'
if($fields && false){
?>
<ul>
<?php
foreach($fields as $field){
?>
<li>
<?php
/*if($field['label']){
echo $field['label'];
}*/
print_ext($field);
?>
</li>
<?php
}
?>
</ul>
<?php
}
EOD;
Put your HTML within the PHP open/close tags and then the /* */ will work fine.