var_export and classes
Today I stumbled upon an old problem while using var_export() on an array with objects. var_exports()'s description is " Outputs or returns a parsable string representation of a variable ", but it didn't work to well in this case:
array (
0 =>
class ezcTranslationData {
public $original = 'Node ID:';
public $translation = 'Knoop ID:';
public $comment = false;
public $status = 0;
},
);
This snippet above can of course not be parsed as valid PHP code. After thinking about it for a bit, I came up with a solution. Instead of the code above, we now generate:
array (
0 =>
ezcTranslationData::__set_state(array(
'original' => 'Node ID:',
'translation' => 'Knoop ID:',
'comment' => false,
'status' => 0,
)),
);
The __set_state() method is then required to be implemented by the class for this to work, but that is better than generating code which can never be parsed. The name comes from the Memento pattern . As this fixes a bug this made it into PHP 5.1.0 and PHP 6.0.0.
Life Line
Updated a restaurant
Updated a restaurant
Updated a restaurant
I walked 5.5km in 56m26s
Created an entrance
I walked 5.7km in 1h20m50s
Updated a fitness_centre; Confirmed a charging_station
I walked 4.0km in 47m13s
I walked 1.1km in 9m32s
Also, whatnow‽
`GET /icons/blank.gif HTTP/1.1" 200 398 "https://downloads.php.net/~windows/pecl/releases/?utm_source=chatgpt.com`
WTF does that need an `utm_source` for?
I sometimes wish cache expiries could be fuzzy, like 900±15 seconds. Y'know, to prevent the thundering herd effect.
Created a chemist shop
I walked 8.1km in 1h24m38s
Updated a bar
Created an entrance and a main entrance
I walked 5.8km in 1h30m43s
Merge branch 'xdebug_3_5'
Back to -dev
Go with 3.5.3
Go with 3.5.2
I walked 7.3km in 1h22m26s
Merge branch 'xdebug_3_5'
Merged pull request #1089
Fixed issue #2424: Control-socket with invalid commands crashes
Merge branch 'xdebug_3_5'

Shortlink
This article has a short URL available: https://drck.me/vac-46l