Skip to content

Resolving common PHP upgrade issues

When upgrading PHP versions on ruachost.com, you may encounter compatibility problems with existing scripts or applications. This guide outlines common issues and how to resolve them.

  • Deprecated functions: Older PHP versions may use functions removed in newer releases.
  • Changed default settings: Configuration directives may behave differently.
  • Extension compatibility: Some extensions are no longer bundled or require manual installation.
  • Syntax changes: Certain language constructs are updated or removed.
  • Functions like mysql_connect() are removed in PHP 7+.

  • Fix: Replace with mysqli or PDO.

    // Old
    $conn = mysql_connect("localhost", "user", "pass");
    // New
    $conn = new mysqli("localhost", "user", "pass", "database");
  • Some servers disable <? ?> short tags.
  • Fix: Use full tags <?php ?> or enable short tags in php.ini.
  • Extensions like mcrypt are removed in PHP 7.2+.
  • Fix: Use openssl or sodium for encryption.
  • set_error_handler() behavior may differ.
  • Fix: Update error handling code to match new standards.
  • PHP 5.6+ defaults to UTF‑8.
  • Fix: Ensure your database and scripts use consistent encoding (utf8mb4).
  • Session storage paths may change.
  • Fix: Verify session.save_path in php.ini and adjust permissions.
  • PHP 7 introduces stricter type checks.
  • Fix: Update code to match expected types or use type declarations.