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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: deemdouxla at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 01:01:35 2025 UTC