I am new to PHP. I started to study it like 3 weeks ago. I can not find the answer to this question in StackOverflow, Google or Youtube. documentation on PHP it just confuses me. To answer the question, how does PHP code work with HTML code?
<?php if (something) { ?>
<p>Hello</p>
<?php } ?>
The p element will only be displayed if something has a true value, like this? ... I definitely thought that the PHP engine ignores what happens around external code blocks (for example, <? Php?>;) And only analyzed what was going on inside.
The code below is usually processed by the PHP engine and sent to the browser without affecting any HTML elements (although it is clearly between the two blocks of code).
<?php echo $something; ?>
<p>Hello</p>
<?php echo $something; ?>
I hope I'm not going to flare up to ask this question, because many people seem to understand how this works, like a tenth of a second.
PS I asked this question in a chat early and thought that I understood correctly, but when I went to implementation, my mind still looked like how it works? I think this is some kind of hack.
source
share