note 115376 added to language.types.array

From: Date: Tue, 15 Jul 2014 09:06:37 +0000
Subject: note 115376 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-199931@lists.php.net to get a copy of this message
Array-to-String conversion by assignment or by using an array in a string context gives a string of data that contains only the word, 'Array' and this data substitution often occurs silently. This happens because the standard PHP installation suppresses Notice-level messages, and the array-to-string conversion, even though it causes data loss, is only considered a Notice condition. Here is how to discern what PHP is doing. http://php.net/manual/en/language.types.array.php http://php.net/manual/en/language.types.string.php#language.types.string.casting <?php // demo/array_to_string.php /** * Starting with the default standard error-level of E_ALL ~ E_NOTICE * OUTPUTS: * Array */ $xyz = array('X', 'Y', 'Z'); echo $xyz; /** * Setting the error-level of E_ALL causes Notice messages to appear * OUTPUTS: * Notice: Array to string conversion in /path/to/demo/array_to_string.php on line XXX * Array */ error_reporting(E_ALL); $xyz = array('X', 'Y', 'Z'); echo $xyz; ---- Server IP: 64.71.164.2 Probable Submitter: 98.169.66.145 ---- Manual Page -- http://php.net/manual/en/language.types.array.php Edit -- https://master.php.net/note/edit/115376 Del: integrated -- https://master.php.net/note/delete/115376/integrated Del: useless -- https://master.php.net/note/delete/115376/useless Del: bad code -- https://master.php.net/note/delete/115376/bad+code Del: spam -- https://master.php.net/note/delete/115376/spam Del: non-english -- https://master.php.net/note/delete/115376/non-english Del: in docs -- https://master.php.net/note/delete/115376/in+docs Del: other reasons-- https://master.php.net/note/delete/115376 Reject -- https://master.php.net/note/reject/115376 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#199931) next »