preview

A Research Study On Global Variables

Better Essays

Above you see an extract from the log in page, showing the heavy dependence on $_SESSION variables. These are required so much because they allow other pages to access the data. If I just used local variables I’d have no ability to transfer data between pages, and this is necessary to keep track of things like who is logged in or if even anyone is logged in. All SQL queries come back as associative arrays too, with each column entry being an element in the array, so they are very prominent.
There are many algorithms implemented in this project throughout to do various things, from checking passwords securely to generating tables for the admin. I will analyse some of these at a later point.
Programming Techniques
Global Variables
Usually, …show more content…

The more difficult questions require more time since they are harder and will take longer. The time setting adjusts the time defined by the difficulty slightly.

You can see what the one and two letter codes mean by looking at the getqcode function on page 4.
Parameter passing
A good example of parameter passing by reference is with the SQL queries, particularly the connection and result. Consider the following:

$con2 is a connection variable that provides access to the MySQL database. This is therefore clearly passed by reference as well as $r, the result since they can have their contents modified by a function and then be used afterwards. On the other hand, in the example above (get_time), the variables $time and $diff are passed by value. They are disconnected from the original when they get passed, changes to them will not affect the original.
Programming practice
One of the most important things in programming is readability and code style in general. It is good if your code runs efficiently and correctly but if anything ever goes wrong with it, it will be a nightmare to deal with if the code isn’t formatted or named correctly. I have therefore tried to give all variables meaningful names so that if I ever look back over the code or make changes, I will know what each bit does. Commenting is also quite important. An algorithm you understood when programming it may end up just looking

Get Access