# [VOTE] var_representation() : readable alternative to var_export()

- Thread: https://externals.io/message/113099
- Original archive: https://news-web.php.net/php.internals/113099
- Started by tyson andre on 2021-02-06T00:38:22+00:00
- Messages: 1
- RFC: var_representation() : readable alternative to var_export() (Declined) — https://externals.io/rfc/readable_var_representation.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #113099 — tyson andre — 2021-02-06T00:38:22+00:00

URL: https://externals.io/message/113099#113099

Hi internals,

Voting has started today on https://wiki.php.net/rfc/readable_var_representation
and closes on 2021-02-19.

This RFC proposes introducing a new function `var_representation`
with the following differences from var_export:

1. `var_representation()` unconditionally returns a string
2. Use `null` instead of `NULL` - the former is recommended by more coding
   guidelines (https://www.php-fig.org/psr/psr-2/).
3. Change the way indentation is done for arrays/objects.
   See ext/standard/tests/general_functions/short_var_export1.phpt
   (e.g. always add 2 spaces, never 3 in objects, and put the array start on the
   same line as the key)
4. Render lists as `"[\n  'item1',\n]"` rather than `"array(\n  0 => 'item1',\n)"`

   Always render empty lists on a single line, render multiline by default when there are 1 or more elements
5. Prepend `\` to class names so that generated code snippets can be used in
   namespaces without any issues.
6. Support `VAR_REPRESENTATION_SINGLE_LINE` in $flags.
   This will use a single-line representation for arrays/objects.
7. Escape control characters("\x00"-"\x1f" and "\x7f"(backspace)) inside of double quoted strings
   instead of single quoted strings with unescaped control characters mixed with ` . "\0" . `.

Thanks,
-Tyson
