help include

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Proximus

    #1

    help include

    hello, at first, sorry on my bad english.

    i have a problem.

    on
    index.php:

    <?
    $include=array(
    "link"=>"link.h tml",
    );
    $stranica="prva .html";
    if(isset($_GET) ){
    $str=array_keys ($_GET);
    if(array_key_ex ists($str[0],$include)){
    $stranica=$incl ude[$str[0]];
    }
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitl ed Document</title>
    </head>
    <body>
    <li><a href="index.php ?pocetna">Pocet na</a></li>
    <li><a href="index.php ?link">linkovi</a></li><br>
    <?php include($strani ca); ?>
    </body>
    </html>


    link.html:

    <?php
    $moj_naslov='li nkovi';
    ?>
    <h2>Linkovi</h2>


    prva.html:

    <?php
    $moj_naslov='pr va stranica';
    ?>
    <h2>Prva Stranica</h2>

    how in index.php to change

    <title>Untitl ed Document</title>

    into <title>linkov i</titleor <title>prva stranica</titledepending what
    is loaded

    "moj_naslov " means "my title"

    thanks from Croatia.




  • petersprc

    #2
    Re: help include

    Here's one way:

    [home.php]
    <?
    $title = 'My Site - Home';
    require('header .php');
    ?>

    <p>Home</p>

    <? require('footer .php') ?>

    [header.php]
    <html>
    <head>
    <title><?= $title ?></title>
    </head>
    <body>

    [footer.php]
    </body>
    </html>

    You can browse to home.php and see your template. If you need an
    index.php controller, you could do:

    [index.php]
    <?

    $pages = array('home' ='', 'services' ='', 'about' ='');

    if (isset($pages[$_GET['page']])) {
    $page = $_GET['page'];
    } else {
    $page = 'home';
    }

    $title = 'My Site';

    require("$page. php");

    ?>

    On Jun 18, 12:14 pm, "Proximus" <veleprodajaOBR ISI...@proximus-os.hr>
    wrote:
    hello, at first, sorry on my bad english.
    >
    i have a problem.
    >
    on
    index.php:
    >
    <?
    $include=array(
    "link"=>"link.h tml",
    );
    $stranica="prva .html";
    if(isset($_GET) ){
    $str=array_keys ($_GET);
    if(array_key_ex ists($str[0],$include)){
    $stranica=$incl ude[$str[0]];
    }}
    >
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitl ed Document</title>
    </head>
    <body>
    <li><a href="index.php ?pocetna">Pocet na</a></li>
    <li><a href="index.php ?link">linkovi</a></li><br>
    <?php include($strani ca); ?>
    </body>
    </html>
    >
    link.html:
    >
    <?php
    $moj_naslov='li nkovi';
    ?>
    <h2>Linkovi</h2>
    >
    prva.html:
    >
    <?php
    $moj_naslov='pr va stranica';
    ?>
    <h2>Prva Stranica</h2>
    >
    how in index.php to change
    >
    <title>Untitl ed Document</title>
    >
    into <title>linkov i</titleor <title>prva stranica</titledepending what
    is loaded
    >
    "moj_naslov " means "my title"
    >
    thanks from Croatia.

    Comment

    Working...