I’ve been talking about PHP a lot recently, but so far I’ve said little about what it is and how it works.
So, What is PHP?
PHP files are a lot like HTML web pages, but also contain these PHP instructions or ‘scripts’. In normal Web browsing, the user requests a file by clicking on a link to it. If this is HTML it is sent directly to them, to be rendered on the screen as text and images by their browser. If it’s a PHP file however it is sent first to the PHP interpreter on the server. Here the scripts it contains are executed and the results – which are always HTML – inserted into the document where the script used to be. Now entirely HTML, it is sent to the user’s browser to be rendered in the usual manner.
So What Can They Do There, These Scripts?
In this way PHP can take requests from a website user, turn them into SQL or some other database query language, and format the results of the query as HTML to send back to the user’s browser where they can be displayed. As I mentioned in the previous post (and the one before that), this is a hugely powerful and flexible technique that can be used for untold purposes. While pages of search results would seem an obvious example, that’s just the nursery slopes. Systems as complex as Facebook are built in PHP. And systems that are good too.
2 replies on “PHP For Very Beginners”
That’s all true, but Lord, tis fugly with its question marks and dollar signs. Demanding on the human eye!
It is not the prettiest, no. Not even by programming code standards. (Which is prettiest I wonder. Python?) The dollar sign for variables is a bit strange, makes me think “Everything has a price”. Maybe it’s because the developer was Dutch and he was just sick of that damn symbol sitting on his keyboard and never doing any work!
The question marks I don’t mind really though. Certainly I strongly prefer them to ASPs¹ percentage symbols. I just think they clash with angle brackets in a really awkward way.
¹(A broadly similar technology from Microsoft.)