Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PHP Questions!

Name: Anonymous 2008-06-03 17:12

<?php
if ($expression) {
    ?>
    <strong>This is true.</strong>
    <?php
} else {
    ?>
    <strong>This is false.</strong>
    <?php
}
?>

I am confused by this code.
Can anyone explain to me what happens if $expression is true? false?

Name: Anonymous 2008-06-05 6:33

>>1
Anything wrapped in <?php and ?> is considered by the PHP interpreter to be code. Anything outside that is regarded as data that may be sent back to the web browser.

So, the program you posted is equivalent to:

<?php
if ($expression) {
    print("<strong>This is true.</strong>");
} else {
    print("<strong>This is false.</strong>");
}
?>


(Actually that will differ slightly in the whitespace output, but it's functionally the same when the HTML is interpreted by the browser.)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List