Skip to content

Instantly share code, notes, and snippets.

@sgk
Created June 15, 2012 01:36
Show Gist options
  • Save sgk/2934126 to your computer and use it in GitHub Desktop.
Save sgk/2934126 to your computer and use it in GitHub Desktop.
Backward compatibility for PHP 5.4
<?
# Add following line in ".htaccess".
# php_value auto_prepend_file compat.php
$HTTP_SERVER_VARS = $_SERVER;
$HTTP_COOKIE_VARS = $_COOKIE;
$HTTP_POST_VARS = $_POST;
$HTTP_GET_VARS = $_GET;
foreach ($_SERVER as $__key => $__value)
$$__key = $__value;
foreach ($_COOKIE as $__key => $__value)
$$__key = $__value;
foreach ($_POST as $__key => $__value)
$$__key = $__value;
foreach ($_GET as $__key => $__value)
$$__key = $__value;
date_default_timezone_set("Asia/Tokyo");
# You have to edit your script to change "htmlspecialchars" to "_htmlspecialchars".
function _htmlspecialchars($s) {
return htmlspecialchars($s, ENT_COMPAT|ENT_HTML401, "EUC-JP");
}
function sqlite3_open($dbfile) {
return new SQLite3($dbfile);
}
function sqlite3_query($db, $query) {
return $db->query($query);
}
function sqlite3_fetch($result) {
return $result->fetchArray();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment