简体   繁体   中英

How to include php file based on navigation bar

Hey guys Id like to know what should I put in my href to include files from my class folder.

My site folder structure

folder-class-head.php
            -home.php
            -setting.php
            -footer.php
      -index.php

This is my head.php look like. What should I fill in the href in order to include the the file in my class folder?

<html>
 <head></head>
 <body>
   <a href="">Home</a> <a href="">Setting</a>

my index.php is that the right way to do if statement?

<?
include "class/head.php";
    <--body start-->
   if (do= home.php){
include "class/home.php";
}

if (do= setting.php){

    include "class/setting.php";
}
<--body end -->
<--footer area-->
include "class/footer.php";
?>

you can add like , &page=home to the href, and check if it is home page,

if($_GET['page']=='home')
{
include "class/home.php";
}

my index.php is that the right way to do if statement?

No. Totally no.

In php, if/elseif/else , those are condition statements, control structure.

do/while represents a loop.

One very common and usual way to load appropriate piece of script with PHP is to use GET SUPERGLOBAL variable.

PHP do/while
PHP if statement
PHP $_GET

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM