I'm setting up a new layout to a webpage and I'm very new to this.. So I have a question to how I should set up the code in my index-file. Should it only include pointers to f.x. "header.php" where the top-picture and topmenu should be, "content.php" to where the text should be and "bottom.php" to where the - well - bottom should be? And within these code what actually is to be coded? Is THAT the smartest way to do it, is it really possible to do it that way? If it ain't the smartest way, what is it then? If this is the way to do it, can somebody please show a php-code of an actual index.php ? I think it's a good way to learn, to just look at the code.
The index page should be set up the same as any other page on your site. If you want to use a common header and footer thats fine. <?php include("header.php"); ?> content here <?php include("footer.php"); ?> PHP:
I would highly recommend including a header/menu/footer file. Otherwise, what happens when you need to change something in one of these? You'll have to change it everywhere! I wouldn't recommend using includes for content -- you would be making a bigger mess that way. I also use includes for ads. I would also get in the habbit of using include_once instead of include. The same goes for require.
yes, you can use include for any page section that you repleat on your web site. For example, I have a news scroller on my web site which is in external php file, and when I want to put that scroller I just use the include(). This way, if I change the scroller it updates on every page.
Another very common way is to use a main index, and include the pages in the part where the content belongs, and have something like /?page=news to access the middle content. INDEX page INDEX page INDEX page include($page.'.php'): <- If you use this, put some error checking on to prevent users manipulating it. INDEX page INDEX page INDEX page
what do you mean "users manipulating it" - you mean your site getting hacked, and if so if this type of coding vunerable?
This might or might not be helpful http://www.digital-web.com/articles/easypeasy_php_2/ Im actually here to try and get a clearer picture myself about your very question!