1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I need To Learn PHP Web Developing

Discussion in 'PHP' started by Vebtools, Feb 1, 2009.

  1. #1
    HI!

    I want to know PHP Web Developing.. i can design easly in html but it is very hard to change in every page like in my web pakistans.com i put iframe as a header so its easy to edit but let me know how to make a single header for all pages in php?

    Thanks in advance
     
    Vebtools, Feb 1, 2009 IP
  2. NuLLByTe

    NuLLByTe Active Member

    Messages:
    382
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    80
    #2
    Well, you have to create a header.php file for example... Put the header content inside it.
    Then, in the index page, write:
    
    <?php
    include_once('header.php');
    ?>
    
    PHP:
     
    NuLLByTe, Feb 1, 2009 IP
  3. mrmaf

    mrmaf Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah the above method is absolutely best approach. Just make a common file and use it in every page by including it!
     
    mrmaf, Feb 2, 2009 IP
  4. InovvativeTech

    InovvativeTech Banned

    Messages:
    32
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Or you can learn smarty its best as the code is separated from design which makes your future site maintenance easier

    www.smarty.net
     
    InovvativeTech, Feb 2, 2009 IP
  5. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #5
    sending a newbie to smarty is like feeding them to the lions.
     
    shallowink, Feb 2, 2009 IP
  6. lifetalk

    lifetalk Well-Known Member

    Messages:
    1,659
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    115
    #6
    Could not agree more!
     
    lifetalk, Feb 2, 2009 IP
  7. bbrez1

    bbrez1 Banned

    Messages:
    208
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    haha nice comparison. @OP: Do it as NuLLByTe said, it's really the easiest way of doing it.
     
    bbrez1, Feb 2, 2009 IP
  8. tech

    tech Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I have also worked on smarty. Its reducing the complexity while debugging.

    It will separate the design with the functionality. So we can easily differentiate when error comes.
     
    tech, Feb 3, 2009 IP
  9. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #9
    include_once() is always costly, just use include();
     
    Kaizoku, Feb 3, 2009 IP
  10. Vebtools

    Vebtools Well-Known Member

    Messages:
    2,619
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    145
    #10
    Guys thanks for help but let me know if my header is in public_html and may index in some other directory then what whould i do for it?
     
    Vebtools, Feb 5, 2009 IP
  11. dc0ded

    dc0ded Well-Known Member

    Messages:
    1,071
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    130
    #11
    :) ha haa haa
    That's a very funny comparison.
     
    dc0ded, Feb 5, 2009 IP
  12. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #12
    Can do a coupla things. The easiest method will be to find out the full path to the file and use it( I would set it as a variable or constant). This is usually something like /home/usrname/public_html/ .

    The quick method is to learn to use the directory structure. Let's say you have /public_html/header.php and there is /public_html/docs/index.php . To include the header you would put this:
    include "../header.php";
    The ../ means go up one level in the file system to find the file. You can keep piling these on if you have to go up multi levels.

    The first method is really best since you would do something like :
    $path = "/home/usr/public_html/";
    This should be in a settings file included before the script starts. When you want to call the header.php file, you would just use the following:
    include $path . "header.php";
    It's better because you don't have to adjust it based on where the calling file is located.
     
    shallowink, Feb 5, 2009 IP
  13. Vebtools

    Vebtools Well-Known Member

    Messages:
    2,619
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    145
    #13
    Thanks dude i wil try it :)
     
    Vebtools, Mar 3, 2009 IP