Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Is it good to use header.php?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #44879
    Rohithzr
    Participant

    I was learning php and found a few articles, one of them was good and i understood php things from there. In that, there was a common Header.php for all files and a footer.php. Now as i am starting to create a new PHP based Forum then

    1. Should I use a common Header.php and Footer.php
    2. I want to create a fluid Layout so is it ok to use Boilerplate.css [Dreamweaver’s Fluid Design option]
    3. Should i design the whole site in html and then convert it to PHP

    Really need suggestions, and I know that this is the best place to get it.

    #135603
    Rohithzr
    Participant

    Well according to what i have designed roughly, I want a same sidebar and footer, so i guess i’ll just use these two as a separate files because i think it is better to have a different title to different pages.

    I was trying to understand what dreamweaver’s fluid design is doing. It is using separate widths for separate devices. Well that is a good thing i guess but what I am unable to understand is will it be able to work like css-tricks.com (reduction in width stacks the divs one under the other). That i am trying to figure out. If You can help me with that then it be great

    For php I thought the same

    Thanks @Melindrea for you valuable information and suggestion!

    #135614
    __
    Participant

    *****
    > Should I use a common Header.php and Footer.php

    Sure, many people start out learning PHP this way.

    *****
    > I want to create a fluid Layout so is it ok to use Boilerplate.css [Dreamweaver’s Fluid Design option]
    …I was trying to understand what dreamweaver’s fluid design is doing

    I don’t know how Dreamweaver does this. If it works for you, go ahead and use it – you’ll need to look at what classes, etc. are available so you can write your own content to take advantage of it.

    *****
    > Should i design the whole site in html and then convert it to PHP

    first, to clarify: you *cannot* “convert HTML to PHP.” PHP is not another way to mark up webpages: it is a programming language that is very good at *writing* HTML markup. What you’re doing is writing PHP that outputs HTML. Observe:

    $php = “HTML”;
    echo “

    Hello, World! I’m writing $php!”;

    That’s your php script; that’s how you see it. PHP runs on your server, and anything it outputs (`print`s, `echo`s, `?>`, etc.) is sent to the visitor’s browser. Browsers read HTML:

    Hello, World! I’m writing HTML!

    *****
    To answer your question, yes: it is often very helpful to design your HTML layout first, because then you can decide which parts are static and which parts need PHP to write them:





    Page Title

    Page Title

    Hello, World! I’m writing HTML!


    Most of this will be the same on every page. In this case, the page title and contents of the article are likely to change depending on the URL that was requested – so, replace those parts with variables:





    <?= $_page_title ?>



    Then, your PHP script can generate that dynamic content and insert it into your HTML *template*:

    # create page title
    # (based on URL, whatever)
    $_page_title = “My First HTML Template”;

    # create article
    # (retrieved from database, etc.)
    $php = “HTML”;
    $content = “Hello, World! I’m writing $php!”;
    $_article_content = “

    $content”;

    # when all your PHP work is *done*,
    # switch to output mode and insert your content into your template:
    ?>



    <?= $_page_title ?>



    #135617
    Rohithzr
    Participant

    > first, to clarify: you cannot “convert HTML to PHP.” PHP is not another way to mark up webpages: it is a programming language that is very good at writing HTML markup.

    well i meant designing the whole working layout in html and then putting scripts and variables as you explained later.

    Thanks a lot for your suggestions and information. appreciate it.

    Now i can start designing my site.

    #135619
    __
    Participant

    >> first, to clarify: you cannot “convert HTML to PHP.” PHP is not another way to mark up webpages: it is a programming language that is very good at writing HTML markup.

    > well i meant designing the whole working layout in html and then putting scripts and variables as you explained later.

    I figured that’s what you meant. But it’s a common misunderstanding, so I thought there was no harm in mentioning it anyway.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.