R
R
raingo2018-01-19 17:08:30
C++ / C#
raingo, 2018-01-19 17:08:30

What is php echo?

What is php echo at the level of client-server communication?
In all textbooks, a deceptive explanation is given: "outputting text to the screen."

spoiler
First, echo doesn't "output" text, it sends it.
Secondly, php echo sends not only "text", but also json for example.
Thirdly, not "on the screen", but in the browser. After that, most often the browser itself displays the received data, but it can also process the received data and does not display it. Depending on the code.

How does echo print text to the screen?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
#
#, 2019-11-05
@Xyyax

oZGq8xg.png

S
Saboteur, 2018-01-19
@raingo

echo by default outputs data not to the screen but to STDOUT.
STDOUT can be redirected to the screen (default), or to a file, or to a browser, and so on, depending on where and how the echo was executed
. json is text.

S
Sergey Gornostaev, 2018-01-19
@sergey-gornostaev

First, echo does exactly that. Outputs data from the script execution environment.
Second, json is one of the text data formats.
Thirdly, the output happens to the output stream. If you run the php script in the console, you will see the result in the console.
Judging by the slurred text under the spoiler, you should delve into the principles of client-server programming in general and the HTTP protocol in particular.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question