PHP Tutorial

Download Java SE 8.

PHP Program Examples - PHP code includes PHP code in another file

PHP code includes PHP code in another file

PHP code from a PHP file can be embedded in another PHP file.

$_SERVER["DOCUMENT_ROOT"] is used to get website root directory

 

isset funtion

 if(isset($_GET['param']))
{
}

In head tag

<html>
<body>
           <?php 
             if(isset($_GET['param'])) {
               $param= $_GET['param'];
               include ('path/'.$param.'.php'); 
             }
             else {
                include ('path/default.php');  
             }
             ?>
</body>
</html>

In body tag


<html>
<head>
             <?php 
             if(isset($_GET['param'])) {
               $param= $_GET['page'];
               include ('path/'.$param.'.php'); 
             }
             else {
                include ('path/default.php');  
             }
             ?>
</head>
<body>
</body>
</html>

no html tag

            <?php 
             if(isset($_GET['param'])) {
               $page_name = $_GET['param'];
               include ('path/'.$param.'.php'); 
             }
             else {
                include ('path/default.php');  
             }
             ?>