# Using old code with new versions of PHP

**URL:** https://forum.kirupa.com/t/using-old-code-with-new-versions-of-php/332542
**Category:** programming
**Created:** [July 18, 2014, 7:07am UTC](https://forum.kirupa.com/t/using-old-code-with-new-versions-of-php/332542 "2014-07-18T07:07:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Astrum](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@Astrum](https://forum.kirupa.com/u/Astrum)
#### Post date: [July 18, 2014, 7:07am UTC](https://forum.kirupa.com/t/using-old-code-with-new-versions-of-php/332542/1 "2014-07-18T07:07:18Z")

</div>

Now that PHP has grown to be a popular scripting language, there are a lot of public repositories and libraries containing code you can reuse. The PHP developers have largely tried to preserve backwards compatibility, so a script written for an older version will run (ideally) without changes in a newer version of PHP. In practice, some changes will usually be needed.

```
     Two of the most important recent changes that affect old code are:     

```

[LIST]  
[_] The deprecation of the old $HTTP\__\_VARS arrays (which need to be indicated as global when used inside a function or method). The following superglobal arrays were introduced in PHP » 4.1.0. They are: $\_GET, $\_POST, $\_COOKIE, $\_SERVER, $\_FILES, $\_ENV, $\_REQUEST, and $_SESSION. The older $HTTP__\_VARS arrays, such as $HTTP\_POST\_VARS, also exist. As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register\_long\_arrays directive.  
[_] External variables are no longer registered in the global scope by default. In other words, as of PHP » 4.2.0 the PHP directive register\_globals is _off_ by default in php.ini. The preferred method of accessing these values is via the superglobal arrays mentioned above. Older scripts, books, and tutorials may rely on this directive being _on_. If it were _on_, for example, one could use $id from the URL _[http://www.example.com/foo.php?id=42](http://www.example.com/foo.php?id=42)_. Whether on or off, $\_GET[‘id’] is available.  
[/LIST]  
For more details on these changes, see the section on predefined variables and links therein.

[SAP Products](http://astrums.net/)
