php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71164 Array to string convertion error
Submitted: 2015-12-19 04:50 UTC Modified: 2015-12-19 04:59 UTC
From: deemdouxla at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.1 OS: Windows 10 x64 Bit
Private report: No CVE-ID: None
 [2015-12-19 04:50 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 04:59 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2015-12-19 04:59 UTC] requinix@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 15:01:30 2024 UTC