Bug #71164 [Opn->Nab]: Array to string convertion error

From: Date: Sat, 19 Dec 2015 04:59:27 +0000
Subject: Bug #71164 [Opn->Nab]: Array to string convertion error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198028@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71164&edit=1 ID: 71164 Updated by: requinix@php.net Reported by: deemdouxla at gmail dot com Summary: Array to string convertion error -Status: Open +Status: Not a bug Type: Bug Package: *General Issues Operating System: Windows 10 x64 Bit PHP Version: 7.0.1 Block user comment: N Private report: N New Comment: Expressions like $obj->$arr[0] are evaluated differently in PHP 7 than before. https://wiki.php.net/rfc/uniform_variable_syntax Use $obj->{$arr[0]} instead. Previous Comments: ------------------------------------------------------------------------ [2015-12-19 04:50:01] deemdouxla at gmail dot com Description: ------------ PHP 7.0.1 Thread Safe on Windows Throws String convertion error. This happened when I tried to access database object Test script: --------------- $obj = $db->results(); $arr = ['tbfield1', 'tbfield2', 'tbfield3']; // Get column tbfield1 $getColumnArray = $obj->$arr[0]; // Then PHP 7.0.1 throws error String convertion error Expected result: ---------------- Return array of column from PHP stdClass Actual result: -------------- ErrorException: Array to string conversion ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71164&edit=1

« previous php.bugs (#198028) next »