I’m working on creating a website, and I’m new to PHP.
Is it better to have .html pages that for button Onclick will call Javascript which will link to a PHP page that communicates with the database and then returns back to the .html page? In my mind this would make PHP a background language and you would never see a .php page in the URL.
Or is it better to make all my pages .php so the html and PHP code can work in the same page? Just curious because I don’t notice a ton of .php URLs
PHP and HTML are complementary not competing languages. PHP is used to create dynamic HTML which will be sent to the viewer.
The extensions don’t make code php or html. HTML code in a
.phpfile is still HTML. by renaming a file to.php, it is simply telling the apache server to look out for php tags(<?php ?>)and if it finds any to engage the php engine.PHP handles the data and HTML is used to format the data. Often called the frontend (HTML) which is what people see, and the backend (the PHP) which is what does the work.