Inserting PHP code inside HTML code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Inserting PHP code inside HTML code

After learning PHP in sololearn I learnt that PHP code can be included inside a HTML code. I tried doing the same using php tags as well using the script tag as given in the php course but still there is no output when I type the php code inside the HTML code. Please help. https://code.sololearn.com/WBl6dsGsplZb/?ref=app

21st May 2021, 10:00 AM
Adhiksit Maji
Adhiksit Maji - avatar
6 Answers
+ 1
Mr. FusionCoder You have to save your file with php extension then you can use PHP. In Sololearn, Web code means HTML, JS and CSS. So when you write code in Web Code and save it then it save with html extension not php extension. So you can't use. You can insert HTML code in PHP but not PHP code in Html. https://code.sololearn.com/w0F7OWCmgFl0/?ref=app
21st May 2021, 11:23 AM
A͢J
A͢J - avatar
+ 2
You may include *html* in your *php* file(afaik), not the other way around
21st May 2021, 10:03 AM
Isaac Fernandes
Isaac Fernandes - avatar
+ 2
Oh thanks a lot 🅰🅹 🅐🅝🅐🅝🅣 thanks a lot for your help now I know how to do it thanks again
21st May 2021, 12:18 PM
Adhiksit Maji
Adhiksit Maji - avatar
+ 1
Yes Isaac Fernandes I have tried but the php code outputs the complete HTML code as well together
21st May 2021, 10:04 AM
Adhiksit Maji
Adhiksit Maji - avatar
+ 1
Have you tried saving it as mycode.php and running it on localhost?
21st May 2021, 10:07 AM
Isaac Fernandes
Isaac Fernandes - avatar
21st May 2021, 10:08 AM
Adhiksit Maji
Adhiksit Maji - avatar