PHP userland backwards compatibility layer that emulates PHP 5.5+ core functions.

⌈⌋ ⎇ branch:  upgrade.php


Check-in [a33d1695b1]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Variant of var_export that utilizes php 5.4 array [] syntax.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a33d1695b1c130aa4239e6898a01d086416cd3b5
User & Date: mario 2014-08-14 07:22:40
Context
2015-05-07
03:41
Fix runkit json_decode mapping, as reported by Lifeboat Fndt. check-in: 87087bb336 user: mario tags: trunk
2014-08-14
07:22
Variant of var_export that utilizes php 5.4 array [] syntax. check-in: a33d1695b1 user: mario tags: trunk
2014-04-27
17:08
Fix json_encode to always output object keys as strings. check-in: 6c8e7d4e1f user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added ext/var_export54.php.















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

function var_export54($var, $indent="") {
    switch (gettype($var)) {
        case "string":
            return '"' . addcslashes($var, "\\\$\"\r\n\t\v\f") . '"';
        case "array":
            $indexed = array_keys($var) === range(0, count($var) - 1);
            $r = [];
            foreach ($var as $key => $value) {
                $r[] = "$indent    "
                     . ($indexed ? "" : var_export54($key) . " => ")
                     . var_export54($value, "$indent    ");
            }
            return "[\n" . implode(",\n", $r) . "\n" . $indent . "]";
        case "boolean":
            return $var ? "TRUE" : "FALSE";
        default:
            return var_export($var, TRUE);
    }
}

print var_export54(["B"=>1.2,"C"=>TRUE,"D"=>3,"E"=>[4,"\\text \"\$here\r\n\t",6,[7,8]]]);