My hosting company is performing database upgrades, PHP4 to PHP5, and MySQL4 to MySQL5. That’s a great news, but I had some hard times updating my old scripts (that is from my clients’ web sites). I did some research and I lost several nights to update all my scripts.
Here’s some quick tips:
1. Lets’s start with the short tags which are off by default, so instead of
<? ... ?> use
<?php ... ?>
2. register_globals is off by default, too. This setting defines whether a variable from
$_COOKIE is automatically recognized in your scripts, so you should change code like this:
if (isset($_POST['something'])) $something=$_POST['something'];
3. The default setting for
magic_quotes_gpc in PHP4 was on, but in PHP5 the option is off by default. This mean that any user input from forms etc that was previously having any embedded quotes automatically escaped with backslashes, will not be treated this way. If your code was written with portability in mind this might already be taken care of, but if you were relying on magic quotes then any user input like O’Reilly will give you problems.
4. PHP 5 might get a bit funny about some OOP notation, and passing references at calltime. However, in the majority of situations, it will just emit an
E_NOTICE or an
E_WARNING error, and carry on as normal.
$_SERVER['PHP_SELF'] instead of
Once a week or so we send an email with our best content. We never bug you, we just send you our latest piece of content.
If you found any value in this post, agree, disagree, or have anything to add - please do. I use comments as my #1 signal for what to write about. Read our comment policy before commenting! Comments such as "Thank you!", "Awesome!", "You're the man!" are either marked as spam or stripped from URL.