PHP was built with the Internet in mind from the start. Unlike Python, it was developed as a general-purpose language.
When you echo from PHP, you are actually writing a stream that is sent to the user as part of the HTTP response. When you print to python, the output is written to the stdout stream by default, which means that instead of sending to the user via http, the output is written to the console (or something that fixes stdout at the moment).
So, for PHP, HTTP is a first class citizen. For more general languages ββlike Python, Ruby, Erlang, C, C ++ and so many other languages. You have to communicate with HTTP in different ways. PHP already handles this connection through apache mod_php or through something like PHP-FPM.
Soooo ...
Regarding the creation of your own server side of the script, I would really like to object to it, since Python Frameworks replaces the layer on which PHP is built. Thus, creating a standard HTTP server as you see fit with Python will not be very simple. The reason this is so complicated is because you have to either interact with CGI or WSGI (the Python standard for working on the Internet), or create your own HTTP server. If you think you are doing the job, I highly recommend it! You probably would have learned a lot by doing this, but it will not be the easiest. The great thing is that so many libraries already care about this post for you. For example, if you are looking for something lightweight, I highly recommend using a microstructure like flask , which I personally use if I need something very simple. It is much easier to start than django, but it also has fewer batteries.
Hope this helps!
source share