The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Saturday, November 13, 2004

Reason #3.1415926 I hate PHP

Continuing with the PHP woes, this time it seemed that PHP wasn't tracking session data. I started to look into this given the minimal script that was provided to prove the problem.

Yup, looked like it wasn't keeping track of the session. Taking a look at the code:

<?php
session_register("yword");
session_register("se");

if (!$yword){
   $wordtext = "Sorry i can't get the session";
}
else
   $wordtext = $yword;
   
if (!$se){
   $setext = "No";
}
else
   $setext = $se;
?>

Started reading the documentation for the session_register() function:

bool session_register ( mixed name [, mixed …])

session_register() accepts a variable number of arguments, any of which can be either a string holding the name of a variable or an array consisting of variable names or other arrays. For each name, session_register() registers the global variable with that name in the current session.

Caution

If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.

register_globals: important note: Since PHP 4.2.0, the default value for the PHP directive register_globals is off. The PHP community encourages all to not rely on this directive but instead use other means, such as the super globals.

PHP: session_register

Not only are they using the wrong function for what they want, but even if it did work, you're not really supposed to use that function anymore, because, you know, it's obsolete (I mean, that's so PHP 4.1.2).

Language du jour I'm telling you! How can anyone use a language with such drastic changes from year to year (or even day to day)? I'm not even going to mention variable variables (it's not that variables in PHP aren't variable enough, it's that this is the PHP way to doing pointers in a langauge that doesn't support pointers but I said I wouldn't mention it, so I won't).

Anyway, the solution to the problem above was to change the code so it looked like:

<?php
$yword = $_SESSION['yword'];
$se    = $_SESSION['se'];
...

And all was right with the world.

Well … almost.

They're still using PHP, which makes using Perl seem almost logical …

Obligatory Picture

An abstract representation of where you're coming from]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

Obligatory AI Disclaimer

No AI was used in the making of this site, unless otherwise noted.

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.