Hello,

I am designing a work portfolio site and I want to use php to put my pages together. I know very minimal of php. I know there is a function called includes. But I can't find any tutorials that explains on the process of setting a website together. Does anyone have a tutorial that I could follow or possibly help me out with this process?

Thanks,

WebDesigner_K

    A pretty useless example, but nevertheless should get you going:

    header.php

    <?php
    
    print '<h1>Welcome to My Site</h1>';
    print '<a href="index.php">Home</a>';
    
    ?>

    footer.php

    <?php
    
    print '<p>Copyright &copy; 2007 YourCompany, Inc.</p>';
    
    ?>

    index.php

    <?php
    
    include('header.php');
    
    print 'this is the main content area';
    
    include('footer.php');
    
    ?>

      What is the point of the print function?

      Thanks for the example!

      WebDesigner_K

        Have a look at the PHP manual for print()

        It outputs a string to the browser.

          You can include files other than PHP files. For example your header file might be

          <h1>Welcome to My Site</h1>
          <a href="index.php">Home</a>

          And you could name it header.php or in this case just header.html if you dont have any PHP in the file.

            jazz_snob wrote:

            You can include files other than PHP files. For example your header file might be

            <h1>Welcome to My Site</h1>
            <a href="index.php">Home</a>

            And you could name it header.php or in this case just header.html if you dont have any PHP in the file.

            Actually, you can name an include file "include.html", "foo.bar", or anything else you'd like to call it even if it does have PHP code in it. The file suffix only matters to the web server when it's deciding whether or not to send an HTTP-requested file to the PHP process; PHP couldn't care less what the suffix is when it is doing an include or require.

              jazz_snob wrote:

              ... or in this case just header.html if you dont have any PHP in the file.

              In which case you shouldn't even be using the include/require() functions at all...

                WebDesigner_K wrote:

                What is the point of the print function?

                to print lol

                :p

                  Write a Reply...