PHP Mixed-Mode Processing

In this chapter you will learn:

  1. What is the PHP Mixed-Mode Processing
  2. Syntax for PHP Mixed-Mode
  3. Example - PHP mix code

Description

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

Syntax


<?PHP//from j  a va2  s. co  m
   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/*from j  av a  2  s  . co  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  java 2s  .  co m
        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
        }
?>

Next chapter...

What you will learn in the next chapter:

  1. Why do we need to include another PHP file
  2. Syntax to include other files
  3. Example - include file
  4. How and when to use require keyword
  5. include_once() and require_once()
Home » PHP Tutorial » PHP Statements
PHP Code Blocks
PHP Comments
PHP if
PHP if else
PHP switch
PHP foreach
PHP while loop
PHP do while loop
PHP for loop
PHP break
PHP continue
PHP Mixed-Mode Processing
PHP include/require