How to organize PHP and HTML code to make an e-commerce?

Asked

Viewed 729 times

-2

I’m doing an e-commerce and I finished planning the site. The site will have to be registered before buying the products, which will be made using Paypal.

My question is: I do the pages with login and no login in HTML and then I put PHP, or I do PHP and put HTML inside PHP?

  • 3

    The order you will make is irrelevant, just do it the way you can test as you develop.

  • Why not start from a base already consolidated, as Magento ?

  • PHP "embeds" html (and often other content), then a page. php supports html content of course, see this answer: http://stackoverflow.com/a/18140338/1518921

2 answers

2

In order terms, the only thing you should keep in mind is the structure itself. Separate scripts PHP of HTML, and so on.

You should also keep in mind that scripts HTML will only be responsible for static content, if you say that this is an online store, there is no reason to force the use of HTML and JS for tasks of PHP, and in the same way, there is no reason to force the PHP generating large amounts of code HTML, since you can use, and I recommend using files with the extension .php, even if they are only responsible for the login form, I believe that a few bytes will not make so much difference.

Anyway, you wouldn’t exactly be organizing your code, you’d be organizing your files. To organize the codes I recommend that you use classes or simply functions, as this is an online store all security is low, just remember this.

If you want to, and you’re definitely going to want to improve the structure, then you should use structures that are already ready, because in addition to being programmed by professionals, thousands of people have already evaluated them, or if you prefer to go old school, you will have to make a lot more effort than choosing where to put the login form.

2


Leonardo, in fact, the order of the factors will not change the final result of your project, but for better visualization and identation of your code, better to be HTML in PHP when PHP predominates in the file in question and vice versa.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.