php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10395 $array[] with no subscript will not return any data
Submitted: 2001-04-19 06:21 UTC Modified: 2001-04-19 08:00 UTC
From: roel at 2e-systems dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.4pl1 OS: Linux
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: roel at 2e-systems dot com
New email:
PHP Version: OS:

 

 [2001-04-19 06:21 UTC] roel at 2e-systems dot com
If you try to use an array without a subscript, no data will
be send back to the browser. Netscape will say 'document
contained no data'; Galeon will display an empty page. The
following script illustrates:

*********8<************
Test.

<?php

echo "this is a test: " . $pr[];

?>
*********8<************

This should imo return at least the first line, then 'this
is a test', and then a warning that $pr[] is invalid.

Configure line (although I think it's not relevant):
'./configure' '--enable-track-vars' '--with-mysql'
'--enable-trans-sid'
'--with-apxs=/usr/local/apache/bin/apxs'
'--with-config-file-path=/etc' '--with-mcrypt' '--enable-shmop'

My php.ini is a bit long to paste here, mail me if needed.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-19 06:51 UTC] hholzgra@php.net
i get
Fatal error:  Cannot use [] for reading ...

you should check your error_reporting settings

 [2001-04-19 07:47 UTC] roel at 2e-systems dot com
I have tried it on both 4.0.4pl1 and 4.0.3pl1, on 4.0.5devel
from halfway february, and 4.0.5devel from today's cvs; on 3
different machines, all with all error reporting turned on.
If I change the test script to have a non-existing string as
index(echo "this is a test: " . $pr['test'];), I get:

Test.
Warning: Undefined variable: pr in /home/roel/test/test2.php
on line 5
this is a test:

which would not appear if I would have error-reporting
turned off. And even if I would have error_reporting turned
off, php should display the rest of the page(the Test.) in
this case), no?  

The relevant part from my php.ini:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; error_reporting is a bit-field.  Add each number up to get
desired error reporting level
;  1 = Normal errors
;  2 = Normal warnings
;  4 = Parser errors
;  8 = Notices - warnings you can ignore, but sometimes
imply a bug (e.g., using an uninitialized variable)
error_reporting =   15
display_errors  =   On ; Print out errors (as a part of the
HTML script)
log_errors  =   On  ; Log errors into a log file
(server-specific log, stderr, or error_log (below))
track_errors    =   Off ; Store the last error/warning
message in $php_errormsg (boolean)
error_prepend_string = "<font color=ff0000>"   ; string to
output before an error message
error_append_string = "</font>"                ; string to
output after an error message
error_log   =   /tmp/php-errors ; log errors to specified file
; error_log =   syslog      ; log errors to syslog (Event
Log on NT, not valid in Windows 95)
warn_plus_overloading   =   Off     ; warn if the + operator
is used with strings

 [2001-04-19 08:00 UTC] hholzgra@php.net
error_reporting =   15

you are re-using a php ini value from php3
this is your problem

php 4 has far more error levels and a value 
of 15 just masks out critical parser errors

you should use

  error_reporting = E_ALL

instead
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Mar 12 11:01:32 2025 UTC