Welcome to WebmasterServe!

FREE TO JOIN! Join us now to engage in informative and friendly discussions about Webmastering, SEO, SEM, Internet Marketing, Programming, Graphic Design, Online Jobs and more. What are you waiting for? Ready to join our friendly community? It takes just one minute to register.

Dismiss Notice

Join WebmasterServe Forums 
Join the discussion! Have a better idea or an opinion? It takes just one minute to register Click Here to Join

Help Me/Question How To Include One Php File Into Other?

Discussion in 'PHP Programming' started by justiinn, Feb 16, 2016.

  1. justiinn

    Yellow Belt

    Joined:
    Feb 3, 2016
    Messages:
    161
    Ratings:
    +28 / -0
    Php is easy to learn and easy to use. I have made php files but i dont know how to include one php file into other php file. I have searched it on google but i didnt understand the logic.
    Can anybody please provide me codes?
     
  2. RADHESHYAM GUPTA

    Yellow Belt

    Joined:
    Feb 13, 2016
    Messages:
    362
    Ratings:
    +20 / -0
    If you have more PHP file and you want to include your PHP file one in to other.
    So you can include by two function:-
    • include()
    • require()
    Such as you have a index.php file, which code is
    <html>
    <head></head>
    <body>
    <a href="...your home webpage address..">Home</a>
    <a href="..your contact us webpage address..">Contuct us</a>
    </body>

    After that you want to create a another php page and include this file in your new file:-
    Suppose your new page page name is Test.php:-

    <html>
    <body>
    <?php
    include (index.php);
    <?
    </body>
    </html>
    When you execute your Test.php file on your Server show your webpage will so this result.

    Home
    Contact us
     
  3. bharath

    Staff Member Yellow Belt

    Joined:
    Dec 7, 2015
    Messages:
    772
    Ratings:
    +54 / -0
    Try downloading a small script that has user login, logout, main page, any 5 pages script. You will get understood in simple steps. Most of the scripts calls using include, require once. Can you tell us what type of SCRIPT you made presently?
     

Share This Page