PHP exceptions, try, catch not working

I was porting over some code a few days ago from a standard standalone PHP script I had written some time ago. I was wanting to use the code inside a larger new web application I was building for personal use.

I was absolutely certain I had copied all of the code line by line into the new program and refactoring it as I went along making sure I did not do anything to break anything.

Everything seemed perfect until I came to run the code and was left baffled by “Uncaught exception” PHP error messages. These error messages did not occur all of the time but only some of the time which made debugging worse.

However due to the nature of the functionality of the code was to be expected as their were aspects of the code that were dependent on an outside source and could be variable.

So I looked through my code and all of the try / catch statements were there and the exceptions as far as the code was concerned should have been handled correctly. I had reached a block that I could not get past, at least for a couple of hours.

After doing some research on Google the answer came to me. I had written my try / catch statements as follows …

The problem was due to name-spacing of the application I was porting the code into. The old standalone PHP script did not use any name-spacing so this was never a problem. The new PHP application did use name-spacing so the try / catch code needed to be written like so …

Notice the “\” symbol. That would be telling the Exception to escape to the global space. After adding these corrections to the code it worked perfectly.

Will HTML be the new assembler?

So I was thinking a while back about skill sets and pay rates for specific skill sets. For example if you can program in Assembler today and a company has a need for a Assembler programmer you can charge big money because there are few Assembler programmers compared to other programmers today.

HTML, CSS, PHP programming languages pay less or rather sometimes pay less because there are a lot of programmers in today’s world concentrating on those languages.

This got me thinking, in the early days of computing there would have been less languages to choose from so there would have been a larger percentage of Assembler programmers around years ago compared to other languages.

However due to the early years of computing being a specific niche anyway there might have been less programmers overall therefore the Assembler programmers got paid big money anyway.

But lets look at it like this, below is diagram of computer languages and the hierarchy of languages which those languages are built on top of …

mockup1

As more programmers start using the languages that are built on top of existing languages less programmers will be an expert in the bottom tier languages.

In today’s world now that we have languages such as PHP, programmers do not need to learn Assembler, programmers do not need to learn C or Java etc. Now that we have frameworks such as JQuery programmers do not even need to learn Javascript.

Now let us pretend we are in the future, 20 years from now. New frameworks have been built on top of HTML. Modern programmers are geared towards learning those new frameworks and they do not need to learn HTML.

HTML programmers have become a rarity and companies needing to fix problems at a lower level such as HTML will need to seek out the specialist HTML programmers.

So basically HTML has now become the new Assembler. With the following aspects …

  1. HTML has become a low tier level language.
  2. HTML has become a rare specialist language, not many programmers will know how to program HTML.
  3. Companies will pay big money for people with skills in HTML.

So that is my view of what might happen in future with the languages we have today like HTML. If you remember how to program in those languages long enough one day they could become a highly paid programmer for those rare specialist languages.

Who would think that in 20 years from now, you could be getting paid £1000 per day for programming HTML?