Приглашаем посетить
CSS (css.find-info.ru)

Section 4.15.  Mixed-Mode Processing

Previous
Table of Contents
Next

4.15. Mixed-Mode Processing

A key concept in PHP is that you can toggle PHP parsing mode whenever and as often as you want, even inside a code block. Here is a basic PHP script:

    <?php
            if ($logged_in =  = true) {
                    print "Lots of stuff here";
                    print "Lots of stuff here";
                    print "Lots of stuff here";
                    print "Lots of stuff here";
                    print "Lots of stuff here";
            }
    ?>

As you can see, there are a lot of print statements that will only be executed if the variable $logged_in is true. All the output is encapsulated into print statements, but PHP allows you to exit the PHP code island while still keeping the if statement code block openhere's how that looks:

    <?php
            if ($logged_in =  = true) {
    ?>
            Lots of stuff here
            Lots of stuff here
            Lots of stuff here
            Lots of stuff here
            Lots of stuff here
    <?php
            }
    ?>

The Lots of stuff here lines are still only sent to output if $logged_in is true, but we exit PHP mode to print it out. We then reenter PHP mode to close the if statement and continueit makes the whole script easier to read.


Previous
Table of Contents
Next