Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
Created December 23, 2011 03:21
Show Gist options
  • Save jehoshua02/1513016 to your computer and use it in GitHub Desktop.
Save jehoshua02/1513016 to your computer and use it in GitHub Desktop.
Yuriy should use git and gist more often

Here's your code revised to use alternate syntax for control structures, convenient for using within templates:

<?php $cont_disp = ($cont_disp); ?>
<?php if ($cont_disp[0] == ""): ?>

    <!-- show nothing -->

<?php else: ?>

    <div id="car-Description" class="box-round">
        <div id="title-text-center">
            <h3>Vechicle Description</h3>
        </div>
        <?php $cont_disp = the_content(); ?>
    </div><!--End car-Description-->

<?php endif; ?>
<?php
$cont_disp = ($cont_disp);
if ($cont_disp[0]=="") { ?>
<!-- show nothing -->
<?php } else {?>
<!--Description-->
<div id="car-Description" class="box-round">
<div id="title-text-center"><h3>Vechicle
Description</h3></div>
<?php $cont_disp = the_content(); ?>
</div><!--End car-Description-->
<!--End Description-->
<?php } ?>

Here's your code revised, to have clean indentation and take advantage of some white space.

<?php

$cont_disp = ($cont_disp);

if ($cont_disp[0]=="") { ?>

    <!-- show nothing -->

<?php } else {?>

    <div id="car-Description" class="box-round">
        <div id="title-text-center">
            <h3>Vechicle Description</h3>
        </div>
        <?php $cont_disp = the_content(); ?>
    </div><!--End car-Description-->

<?php } ?>

Can you spot your problem now?

Here's your code, with my comments pointing out questionable areas:

<?php $cont_disp = ($cont_disp); /* <-- this looks wierd . . . */ ?>
<?php if ($cont_disp[0] == ""):
/* What is the value of $cont_disp[0]? What were you expecting? */ ?>

    <!-- show nothing -->

<?php else: ?>

    <div id="car-Description" class="box-round">
        <div id="title-text-center">
            <h3>Vechicle Description</h3>
        </div>
        <?php $cont_disp = the_content();
        /* What does the_content() function return?
        Did you mean to `echo` something here? */ ?>
    </div><!--End car-Description-->

<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment