PHP Mixed-Mode Processing

Description

PHP mixed-mode processing would allow us to mix PHP code with HTML code in the same page.

Syntax


<?PHP//  w  w  w .ja  v a 2  s.c om
   PHP code block start
?>

   HTML code

<?PHP
  PHP code block end
?>

Example

We can toggle PHP parsing mode. Here is a basic PHP script:


<?php// w w w  .j  a v  a  2s  . c o m
        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";
        }
?>

The code above can be rewrite as the follows.


<?php/*from  www.  java 2  s. c  om*/
        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
        }
?>




















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition