2

In a php script: -What is the difference between

echo "<p>info</p>"

and simply writting html content (what include "htmlfile" basically does)?

include "file.html"

Observation: I read that echo sends a command to web server to send http response, while including a html file waits till the processing php code is done.

In the latter case, does the php module "echoes" at the end of the processing all the html that was written in the php file?

Thank you!

1 Answer 1

1

Here is what I realised:

  1. A php engine does the following:

-takes the php file

-if it encounters html tags (outside any php tag), it sends to output buffer

-if it encounters php tags, it execute php code inside.

  1. Include file.html statement does the same thing as above, with the observation that all code is analysed sequentially, from top to bottom. From here it comes the misunderstanding that include statements actually copy paste code. No. It involves a mechanism of analysing and/or executing.
  2. Echo sends directly to output buffer
  3. You can't have html tags directly inside php tags.

I hope this can be helping for you in case you have wonders like mine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.