#97. PHP Include_once & Require_once

How to Create PHP Include_once & Require_once?



Code:

form.php

<!DOCTYPE html>
<html>
<head>
    <title>Page Layout</title>
    <style>
        .sidebar {
  height: 100%;
  width: 200px;
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  background-color: #111;
  overflow-x: hidden;
  padding-top: 20px;
}

.sidebar a {
  padding: 6px 6px 6px 32px;
  text-decoration: none;
  font-size: 25px;
  color: #818181;
  display: block;
}

.sidebar a:hover {
  color: #f1f1f1;
}

        .head1 {
            font-size:40px;
            color:#009900;
            font-weight:bold;
        }
        .head2 {
            font-size:17px;
            margin-left:10px;
            margin-bottom:15px;
        }
        body {
    margin: 0px auto;
    background-position: center;
    background-size: auto;
    padding-left: 17%;
    padding-right: 1%;
}
     
        .menu {
            position: sticky;
            top: 0;
            background-color: #009900;
            padding:10px 0px 10px 0px;
            color:white;
            margin: 0 auto;
            overflow: hidden;
        }
        .menu a {
            float: left;
            color: white;
            text-align: center;
            padding: 14px 16px;
            text-decoration: none;
            font-size: 20px;
        }
        .menu-log {
            right: auto;
            float: right;
        }
        #footer {
    width: 100%;
    bottom: 0px;
    background-color: #000;
    color: #fff;
    position: absolute;
    padding-top: 1px;
    padding-bottom: 2px;
    text-align: center;
    font-size: 15px;
    font-weight: 100;
    margin-left: -19%;
    margin-right: 4%;
}
        .body_sec {
            margin-left:20px;
        }
    </style>
</head>
 
<body>
      //include_once & require_once are same work but if multiple bar exist then can't display.
<?php include_once 'header.php'; ?>

<?php include 'sidebar.php'; ?>
 
    <!-- Body section -->
    <main class = "body_sec">
        <section id="Content">
            <h3>Content section</h3>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
                standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it
                to make a type specimen book. It has survived not only five centuries, but also the leap into electronic
                typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
                sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker
                including versions of Lorem Ipsum. It was popularised in the 1960s with the release of Letraset sheets containing
                Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
                of Lorem Ipsum. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
                printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five
                centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
            </p>
            <ul class="list">
                <li>Lorem Ipsum dolor sit amet.</li>
                <li>Modi nihil in animi necessitatatibus.</li>
                <li>consectetur adipiscing elit.</li>
                <li>Lorem Ipsum dolor sit amet.</li>
                <li>Sed at sagittis lorem, vitae egestas nulla.</li>
            </ul>
        </section>

        <?php include 'footer.php'; ?>
       
      </main>
     
   
</body>
</html>

header.php

<!-- Header Section -->
<header>
        <div class="head1">PHP Web</div>
    </header>
     
    <!-- Menu Navigation Bar -->
    <nav class="menu">
        <a href="#home">HOME</a>
        <a href="#news">NEWS</a>
        <a href="#about">About</a>
        <a href="#contact">Contact</a>
      </nav>

sidebar.php

<div class="sidebar">
    <ul>
        <li>
            <a href="#">Home</a>
        </li>
        <li>
            <a href="#">News</a>
        </li>
        <li>
            <a href="#">Contact</a>
        </li>
        <li>
            <a href="#">About</a>
        </li>
    </ul>
</div>

footer.php

<!-- Footer Section -->
<div id="footer">
    phpweb@copyright2022.
</div>


Comments

Popular posts from this blog

#30. PHP Recursive Function