As I think I mentioned before I have written some ugly PHP pages to simplify my testing work (seriously, thanks to a couple of fairly simple pages I have taken the time that it takes to test our content server down to half an hour, while before it took the better part of a day).

Anyhow, I recently got a new laptop, so one of the first things I did (of course was set up Apache/PHP/MySQL so I had my test/dev environment back and I noticed that, just like on my own laptop only one page of the PHP tests broke.

The lines that broke looked like:

<li>Download a <a href=”<?=get_signed_url(“videos/”.$main_video.”.mp4″,3600,$main_secret)?>”>correctly signed video</a></li>

ann I couldn’t figure out for the life of me why this broke while the rest worked. To make matters worse, this was code a colleague wrote for me because I had issues figuring out how to call functions while echo-ing text in the first place.

Of course I tried googling, but searching for syntaxy things is always kinda complicated, so in the end I took to good olde-timey detective work:

  1. Compare PHP versions (on my new laptop PHP was slightly newer, but the difference was so small that it shouldn’t have a significant impact).
  2. Compare the php.ini files on both machines (I was pretty sure that it was a configuration thing) and spot the differences.

It turns out that the main difference that jumped to the front was the that a property called short_open_tag was turned off on my new machine. This sounded like a very likely cause of the issue I was seeing so I changed it and, lo and behold, everything worked all of a sudden.

So, I’m done, right?

Well, no, not really, it looks like short open tags can be a bit of a liability and are recommended against for production servers, so I decided to fix it (so next time I get a new machine I don’t need to reinvent the wheel).

To do that, I had to rewrite <?= to proper long form PHP. With a bit of googling I found a relevant Stack exchange thread where someone was fixing the same issue, so I changed <?= to <?php echo, turned off the short_open_tag in PHP again, restarted Apache, and all of a sudden everything works beautifully once again.

Advertisements