bayesian inference in php

I recently came across an article on IBM's website entitled Implement Bayesian inference using PHP, Part 1. There are also two other parts, which are linked to from that page. Not only are these articles helpful at understanding Bayesian probabilities, they include sample source code for actually using them in PHP. There are even some helpful demo pages. I found this interesting because I have been toying with the idea of using PHP to calculate and display Bayesian probabilites for quite some time.

So, I downloaded the code and installed it on my server. I quickly noticed, however, that some of the code did not work. The reason for this is that it is old code, which was written at a time when the default security settings for PHP were much more lax. They allowed you to access user-supplied variables directly, in the same way you would hard-coded variable. This was bad, because it also meant that users could overwrite your hardcoded variables if you were not careful, and could change the way the program would function. Nowadays, user-supplied variables usually have to be accessed differently, which makes websites more secure.

I'm working on updating this code to work in such new environments. This is not a big deal because the fix is really easy, and most of the people who would be interested in this could probably figure it out on their own. But just in case someone finds it helpful, here it is:

Part 1
Part 2 (coming soon)
Part 3 (coming soon)