HTML in a PHP code? | Sololearn: Learn to code for FREE!


HTML in a PHP code?

I know you can put HTML in a PHP code. My questions are: 1. why can you put HTML in a PHP code? 2. can you put HTML in any other coding language?

1/7/2021 4:48:51 PM

Brain & Bones

10 Answers

New Answer


Caleb originally PHP required print statements like perl or python, but I think when it was rewrote to use the zend engine they just started passing thru anything that wasn't encapsulated in the php tags as raw data, so the responsibility to interpret any language rests on the client and php just ignores that syntax. It is handy. I think the modern browsers have a lot to do with it, they handle a lot of irregularities without crashing, and that was not always the case either. I remember writing PHP3 code and it could be a real pain sometimes. You could spend hours debugging code, staring at a blank browser window and reading thru logs to find all the errors. I really enjoy PHP7, and haven't looked at PHP8 yet, but from what I have read it is even more amazing!


This method is especially useful if you have a lot of HTML code but want to also include PHP. As you can see, you can use any HTML you want without doing anything special or extra in your PHP file, as long as it's outside and separate from the PHP tags.


I think You can't put html in php You can put PHP in html


No only php.


I'd say that depends. When using CGI, you can for example also use python to output html, simply by print-statements #!/usr/bin/python print "Content-type:text/html\r\n\r\n" print '<html>' print '<head>' print '<title>Hello World</title>' print '</head>' print '<body>' print '<h2>Hello World! </h2>' print '</body>' print '</html>' Here's a link in case you're interested in that topic:


Php was designed that way.


React code includes JSX that also looks like HTML.


you can use html with php css javascript


Melekte Petros You can definitely put HTML inside PHP... along with inline CSS and any scripting language you can embed in HTML that the client can understand: