Tag: JavaScript

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?

It’s a programming language, used to greatly increase the capabilities of a website. In this way it’s very comparable to JavaScript, and can even be seen as its complement. Both are ‘scripting’ languages. Unlike ordinary programs which are written in human-readable code and then ‘compiled’ to the binary instructions that computers can execute, scripts stay human-readable. Their code is executed by an interpreter program. With JavaScript, that program is your Web browser – any script in a web page you view actually runs as a program on your own computer. PHP however is interpreted by the PHP program, and this must be installed on the computer where the web page is held – the web server. For this reason it’s described as a ‘server-side scripting language’.

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?

It’s really just a programming language like any other. If you already know one of the more popular ones – C++, JavaScript, Perl – it will all look pretty familiar.¹ So you could use it for any computational purpose imaginable (it is ‘Turing complete’, as the theorists say). I wouldn’t though. What makes PHP special is not so much what it is as where it is: Sitting between the HTML and a database on a web server, allowing one to talk to the other.

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.

¹Don’t worry if you don’t, there is much you can do with PHP without knowing any programming at all. Thanks to the likes of WordPress, Drupal, Joomla and many more, you can install and run a PHP-based site without speaking a word of the language.

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?

It’s a programming language, used to greatly increase the capabilities of a website. In this way it’s very comparable to JavaScript, and can even be seen as its complement. Both are ‘scripting’ languages. Unlike ordinary programs which are written in human-readable code and then ‘compiled’ to the binary instructions that computers can execute, scripts stay human-readable. Their code is executed by an interpreter program. With JavaScript, that program is your Web browser – any script in a web page you view actually runs as a program on your own computer. PHP however is interpreted by the PHP program, and this must be installed on the computer where the web page is held – the web server. For this reason it’s described as a ‘server-side scripting language’.

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?

It’s really just a programming language like any other. If you already know one of the more popular ones – C++, JavaScript, Perl – it will all look pretty familiar.¹ So you could use it for any computational purpose imaginable (it is ‘Turing complete’, as the theorists say). I wouldn’t though. What makes PHP special is not so much what it is as where it is: Sitting between the HTML and a database on a web server, allowing one to talk to the other.

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.

¹Don’t worry if you don’t, there is much you can do with PHP without knowing any programming at all. Thanks to the likes of WordPress, Drupal, Joomla and many more, you can install and run a PHP-based site without speaking a word of the language.

The back-kitchen / laundry / scullery / workroom / conservatory / toolshed at my parents’ house hadn’t really been tidied since my father died – or indeed many years before. I was not looking forward to this.

But it’s a revelation, literally. The last time this wall was fully visible it was the 1990s. Ever since it’s been obscured by “temporary” shelves – and the crap that inevitably accumulated on them. Stuff in jars and tins, mostly. Nuts, screws, washers, and bolts. So many, many different sorts of nail.

I’m slightly amazed to see the stonework properly again. Ideally I’d take this opportunity to repoint it, but there’s only so much summer and a lot of jobs to do. So many, many jobs. I’ve a range and a washstand to restore, a home Ethernet/satellite network to complete, two websites to design, a laptop to refurbish and an entire programming language (JavaScript) to learn before college starts again in little more than a month. Hmm… To finish this job alone, I’m going to have to sort out all the tools. That may not sound too fearsome, until you realise how many, many kinds of tools there are. Two entire sets of spanners and sockets (my Dad’s old imperial and my metric one – there’s a generational change), plumbing tools, wood tools, electrical tools, car tools, power tools, gardening tools, broken tools. All these have to be separated out. And where do gas fittings go? Welding rods? We don’t even have an arc welder any more.

A lot has to go. Two generations of male “But it’s useful!” thinking has its consequences. If you click on the picture to zoom in you’ll see a thing that looks like a green raygun. That’s a car timing strobe. I don’t think anyone even makes a car with mechanical timing any more. It will be a wrench though. Each bit will be a wrench. I hauled out a fridge today, one that my father once cannily converted into a chest freezer by the simple expedient of laying it on its back. It’s a strange shade of pale blue-green inside, it was made in Italy, and it’s probably the first fridge I ever saw. And I’m going to send it to a dump.

I came across a pair of metal… things. Just matching stamped pieces of steel. I do not know what they are, what they were once part of. Beyond some educated guesswork based on their shape, I don’t know what they are meant to do. But I know they’re important. The one thing I do recall about them is that at some point they were the key to a problem I wrestled with. A long-forgotten problem. How can you throw away something like that?

OK, just me then.

But the space must be made. Firstly, so that there is some chance of ever finding a thing. Because at the moment it’s organised on the principle “A place for everything, and everything in that place”. Secondly, so that there’s some space in this space. Because this is actually a great space. (Now I’m an interior designer I’m forbidden to use the word “room”.) The light is extremely good. All right, the transparent roof makes it too hot to breathe in during summer, and the gap between that roof and the top of the wall makes it icy in winter. But for… the many, many days between this could be a good place. Not just for storage and drying laundry, but to work or relax in.

Wonder can I bring the Ethernet out here.

Related articles

Some Screenshots:

Multitasking, something of an afterthought until now, becomes integral in Android 4 (Ice Cream Sandwich). Hold the home button and every app you’ve used recently is there waiting to take up from where you left off. Well I say recently; presumably it’s limited by available memory, but it seems able to hold dozens.

That “Deck of Cards” view in Google Chrome Beta for mobile, allowing you to flick through your open tabs. This is a really good idea.

Another feature of the new Chrome browser – preview of search results. Touch a small magnifying glass icon in the results and screenshots are spread out for you. It’s remarkably fast too.

In short, I love this browser! It’s not perfect yet; it crashed once, and it took me a while to coax it into allowing me to upload those screenshots. (Tip: Zoom out. When screen is magnified, WordPress can get confused about which link you’re pressing.) But I created this post using it exclusively, a real-world challenge involving complex JavaScript-heavy pages and devilish floating input panels. The only mobile browser to even barely pass before this was Nokia’sMicroB, which is essentially desktop Firefox for Linux in a mobile guise. To finally surpass this is high praise indeed – and an indictment of other mobile browsers when you consider that they’re still behind a standard Nokia set three years ago.

Anyway, the take-home here is that mobile browsing finally works right. Well done, Google.

The latest version of Android is at last available for Samsung’s Galaxy Note!

Well, kind of. If you live in certain parts of Germany, and perhaps downwind. No one is sure when carriers will actually make it available in their location.

Tired of waiting I cracked, and installed Ice Cream Sandwich myself. A caveat then: As far as I know the version I am using is precisely the one that Samsung released to carriers in Ireland¹, but there may be more to be done with it before the networks roll it out. Particularly, while it appears to be the latest version of Android (4.0.3) complete with Samsung’s “TouchWiz” top layer, not all of the much-publicised Premium Suite seems to be present.

(The only obvious inclusion in fact is S Note, which seems to be a more capable replacement for the – already very useful – S Memo note-taking and sketching app.)

Anyway, that’s all beside the point. What’s it like!?! The initial impression might be a little disappointing – it hardly seems to have changed at all. But that’s because the front end is still Samsung’s TouchWiz customisation. Look closer and you begin to see quite the opposite – everything has changed. There hardly seems to be a single element of Android that hasn’t been either subtly or radically improved. This really is a new OS. It shows best perhaps in an improved tightness, in a great many more options and details, more fancy transitions. All in all, just a nicer overall experience.

For me of course, what matters most is the pen functions. And the good news is, my hopes are realised. That little dot appears on the screen to show it tracking the pen tip, so you know exactly where your line is going to appear when you draw. As odd as that might sound to those who haven’t tried it, this makes drawing far more spontaneous and intuitive. And the pen seems to have become even more responsive too. As you can see above, it gives you a natural, ink-like line. I can say unequivocally now that this must be the best pocket-sized electronic sketchpad you can acquire.

The wider public I think will be more impressed by something that doesn’t actually come with Ice Cream Sandwich, but requires it: The beta version of the new mobile Chrome browser. On a big screen like the Note’s you can set it to act like a desktop browser, and it can deal with complex, JavaScript-laden sites such as editing WordPress. Clever pop-up magnifications help you choose small menu items, and it employs a metaphor that stretches back to PalmOS, the lost rival mobile system, and even all the way to the original WAP mobile browser – that of a “deck of cards”. Open tabs can be viewed almost as if they were a poker hand, and unwanted ones can be flicked away. It’s all very cute and fluidly animated, basically making other mobile browsers – even Apple’s – look crude and unfinished. And it’s still in beta.

This alone makes the upgrade something to look forward to. Hang on, it can’t be much longer now! And if you are thinking of buying a Samsung Galaxy Note, be assured that the bits that seemed rough on release are now smooth. The fabulous tablet-phone just got more fabulous.

As well as Vodafone, The Samsung Galaxy Note is now available in Ireland from 3 and O2.

For the more technically inclined reader: The ROM I installed came from here; to flash it I used Odin, a simple process that doesn’t even require you to root. Note that I am NOT recommending you try this yourself. It almost certainly voids your warranty, and there is a non-zero chance that it will irretrievably destroy your phone.

Related articles

Remember when people just, you know, made phones? That was so crazy. Now you don’t stand a chance unless you have a whole “ecosystem” of app developers, electronics companies, service providers, accessory makers and so on.

Incompatible systems, locked in a death match; the fewer there are after all, the more profitable they will be. We’ve already seen promising contenders like Symbian, WebOS and MeeGo fall away, Blackberry and even Windows Phone have question marks over them. So why is an organisation like Mozilla, the not-for-profit foundation best known for the excellent Firefox browser, entering this ring?

Well they have one advantage over the others, and I just mentioned it: They don’t have to make a profit. They don’t need the support of a mutually beneficial ecosystem. But if they don’t want the money, why do it at all? There’s one good reason: To preserve and protect the Web. As a foundation set up to create a free, open Web browser back in the days when it looked like Microsoft was going to take it all, they could be said to have a legitimate interest here.

Only this time, they have to save the Web from Apple.

Look at Apple’s business model. To a large extent it consists of taking things that the Web could deliver for free and offering them – via an app – as a service you pay for. This is especially attractive to publishers and others who are looking to control distribution, holding out hope for a future where people will need certain apps running on certain devices to access their content. It’s not hard to see a danger here of splitting the Web into proprietary channels.

To compete with the rising popularity of apps, the Web has to be able to do everything an app can do. Mozilla believes the answer is Boot To Gecko, or B2G.

Gecko is the “engine” of Firefox (and other related browsers), the program that turns the HTML, CSS and JavaScript that pages are written in into the visual, interactive experience on your screen. The idea is simple but unexpected: Why not write the whole phone in these languages? Compare this to Google’s system; Android has a little Linux for the fundamentals, then on top of that it runs a Java engine called Dalvik. So the interface and the apps of Android – including the browser – are all written in this version of Java.

B2G also has a little Linux, but running right on top of that is the browser (Gecko). Everything else then, from the interface to the Web pages it brings you, is in HTML/CSS/JavaScript. It’s a drastic simplification. Writing apps for it will be like – indeed, will be – Web development.

Unlike the average Web browser today though, B2G will have greatly-heightened awareness of the hardware it is running on, and this will allow app-like integration between the device and online data. Better still though, it can integrate them via the Web. A sufficiently “intelligent” page would be able to accept all the different kinds of input data your phone can provide. To take a fairly obvious example, an icon on Facebook could launch your camera and upload an image seamlessly.

One big question remains: If nothing is locked-in, if no one can make money by selling apps and services, who is going to make and sell the hardware? Surely not the big two or three who almost have the market sewn up between them. The answer might be: Everybody else. With B2G freely available, maybe people can just… make phones.