Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
Html files can't have PHP code in them unless you instruct your web server to parse HTML files with the PHP interpreter which is a bad practice. But is valid to have HTML code in PHP files, the interpreter will simply ignore and output anything that isn't between the PHP tags.
2nd May 2019, 10:18 AM
Andrei O
Andrei O - avatar
+ 7
PHP is a server side scripting language. When you post a form, you will commonly see <form action="myphp.php"> </form> When you do this, you are sending all of the forms data to a PHP file called myphp.php. However, say you have a messaging application and you want to get data from a PHP file. How can we do this? Well, the method is called Ajax. Ajax consists of XmlHttpRequest and fetch. These are functions that are used to get data asynchronously. --- I would recommend that you have a look at MDN for XmlHttpRequest first as it will give you a much richer understanding of Ajax. Hope it helps 😃
1st May 2019, 10:03 PM
Edwin Pratt
Edwin Pratt - avatar
+ 3
When building a complex page, at some point you will be faced with the need to combine PHP and HTML to achieve your needed results. At first point, this can seem complicated, since PHP and HTML are two separate languages, but this is not the case. PHP is designed to interact with HTML and PHP scripts can be included in an HTML page without a problem. In an HTML page, PHP code is enclosed within special PHP tags. When a visitor opens the page, the server processes the PHP code and then sends the output (not the PHP code itself) to the visitor's browser. Actually it is quite simple to integrate HTML and PHP. A PHP script can be treated as an HTML page, with bits of PHP inserted here and there. Anything in a PHP script that is not contained within <?php ?> tags is ignored by the PHP compiler and passed directly to the web browser.
2nd May 2019, 3:18 AM
Galih Prakoso
Galih Prakoso - avatar
+ 3
Using require or include html file in php...Easy method for call
3rd May 2019, 3:22 AM
Abhishek Bakhai
Abhishek Bakhai - avatar
+ 2
Used require Or include html file in your php file
2nd May 2019, 2:08 PM
Rahman Rezaie 🇦🇫
Rahman Rezaie 🇦🇫 - avatar
0
Just change the extention of your HTML file to php, and include the other php file by calling the require method.
3rd May 2019, 6:14 PM
James McLain
James McLain - avatar
- 2
Lama
2nd May 2019, 7:25 AM
Aakash lama
Aakash lama - avatar
- 2
Cv
2nd May 2019, 3:51 PM
Youssef Mahboub
Youssef Mahboub - avatar