1

I see all websites (THE big ones) make both PHP and HTML in same page .. Do I need to make all my website pages as PHP and embedded HTML inside it ? Can't I make the website all as HTML Pages and PHP pages separate and the required output of PHP page I make a separate HTML for it ? i need an explanation or advice for the best approach . I searched SO for appropriate answer but no luck .thanks in advance .

2
  • 4
    I don't think you fully understand PHP's role in web site creation. This might be of help: stackoverflow.com/questions/12126684 Commented Jun 16, 2016 at 18:20
  • Where and how are you seeing "PHP and HTML in the same page"? If you are seeing PHP code in the browser, then that is certainly not a secure page/site.
    – HorusKol
    Commented Jun 16, 2016 at 23:02

4 Answers 4

2

Ahmed,

Web pages can be built in just html. In fact, that's how the web started out: with just simple html pages, things we would call today "brochure-ware". The user requests a page and the server delivers a mixture of text and pictures, and then it's done. There is no interactivity, like individual preferences or searching a database.

PHP came later as an easy way to add some programming logic - choosing this or that - to web pages, then providing easy interface to databases to search for stuff and return the results.

The page delivered to the user is ALWAYS just HTML plus maybe some javascript, because that's all the user's browser can display. The PHP is programming that happens back on the server to decide what HTML to deliver to the user. A web page can be written entirely in PHP, but the PHP will be designed to print ("echo") HTML code back to the user. Hope that helps.

1

I see all websites (THE big ones) make both PHP and HTML in same page .. Do I need to make all my website pages as PHP and embedded HTML inside it ?

The fundamental problem here is that you're seeing a thing that websites you perceive as being big ones and then you're assuming that's a good thing to do.

It's not.

PHP is terrible enough on its own; embedding HTML and PHP in the same page will only make things even worse. The correct structure of a Web application is to have a strictly separated client and server.

As a disproof-by-counterexample, a simple example of a big website that does not have PHP and HTML in the same page is Facebook - they developed React which is very opposite this perspective.

0

Yes you can avoid PHP inside HTML. Use PHP as an API. Load up the page with embedded JSON, and render out the page client side with JavaScript. Then, instead of requesting HTML/PHP via AJAX, request more info formatted as JSON.

0

Yesm all of these things are correct but in the end when every page is loaded they are all converted to an HTML formatting so basically PHP, Bootstrap, CSS, JS are just basically all additions with makes data entry or forums all possible but the real question is what will this be used for and how can we , you implement an infrastructure for storing all data entry from account ids to arrays and strings , etc

Correct me if I am wrong though

1
  • 1
    Javascript and CSS are not converted to HTML formatting; only PHP and Bootstrap are. Commented Jun 17, 2016 at 18:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.