Help me !!! Im new to PHP :)

hi everyone,
im new to php. i designed a shopping portal and now it is completely functional.
but my friend told designing all the pages with php is not an efficient one.
i used “include” to link the header, menu and the footer in every page
my pages wil look like this

include(“header.php”);
include(“menu.php”);

// page content in php or html

include(“footer.php”);

is this method is ok or do i have to change my approach
if this is not efficient please explain ur approach

PLEASE HELP ME WITH THIS !!!
THANKS IN ADVANCE !!!

:slight_smile:

Hi there,

What your friend said is somewhat true. You will always want to separate the design aspect of a site from the logical component. It’s just better to maintain, that’s all. If you have all of your code using PHP, if others would like to change your website design in the future, they would have to know some PHP in order to do so. However, if you have all of the design aspect in HTML (separate from PHP), others would not have any issues with the redesigning of the page; and the people, like yourself, would only have to worry about the PHP part of the site. Now, if you are the only one who is ever going to do anything with your site, it doesn’t matter how you do it as you would understand how PHP is run and can change whatever you want at any time.

What you have in your code snippet is fine. However, if you want to separate design from logic, just put HTML in your header and footer pages and that would be fine. What it all comes down to is organization. Most people prefer to have all of their HTML in one place and their PHP in another. It just good business practice and a must if you want to ever become apart of a web designing team at a corporation. If this is just for yourself and no one else, it doesn’t mater what you do, it is your site.

Hope this helps.

Hi OpzMaster,
Thank you soooo much for your reply :slight_smile: :slight_smile:

you said that
“However, if you want to separate design from logic, just put HTML in your header and footer pages and that would be fine.”
i cant understand that !!!

Let me add something to my question.
In my site i want my header to be refreshed each time a page loads because it has some nos. and they will change according to user action,
and even my home page is dynamic it shows last added item in the cart,
so i cant do that with HTML, but i understood what you are saying.

sorry if this sounds awkward to you, i am very new to php and i developed this site within 5 days by side by side learning php. so i dont know all the details please help me understand.

you said to seperate logic and design but my design itself needs php scripts what to do !!!
please help me.

so leaving the design as php is ok???
please please please help me !!!

Thanks in advance
:slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service