Bug #75232 [NEW]: print_r creating side-effect.
| From: | ben at redsnapper dot net | Date: | Wed, 20 Sep 2017 08:38:43 +0000 |
| Subject: | Bug #75232 [NEW]: print_r creating side-effect. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-211258@lists.php.net to get a copy of this message | ||
From: ben at redsnapper dot net
Operating system: any
PHP version: 7.1.9
Package: Date/time related
Bug Type: Bug
Bug description:print_r creating side-effect.
Description:
------------
Using print_r on a DateTime object creates a side-effect: the property
'date' is now set and publicly available.
Test script:
---------------
//Expected Behaviour
php > $d1 = DateTime::createFromFormat("Ymd\THis\Z",
'20170920T091600Z');
php > echo $d1->date;
Notice: Undefined property: DateTime::$date
//Unexpected Behaviour / side effect.
php > $d2 = DateTime::createFromFormat("Ymd\THis\Z",
'20170920T091600Z');
php > print_r($d2->date);
DateTime Object
(
[date] => 2017-09-20 09:16:00.000000
[timezone_type] => 3
[timezone] => UTC
)
php > echo $d2->date;
2017-09-20 09:16:00.000000
Expected result:
----------------
There should be no change (side-effect) made to an object when using
print_r()
--
Edit bug report at https://bugs.php.net/bug.php?id=75232&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75232&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75232&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75232&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75232&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75232&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75232&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75232&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75232&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75232&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75232&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75232&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75232&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75232&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75232&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75232&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75232&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75232&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75232&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75232&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75232&r=mysqlcfg