note 102526 added to function.fgetcsv

[email protected] Fri, 18 Feb 2011 17:23:03 -0800
Newsgroups php.notes
Message-ID <[email protected]>
NOTE: i think the example in this page should be changed. I think the following line should be added to just inside the while loop:

if( $data === true ) die('PAY ATTENTION DUMMY');

The reasoning for this, is if the user happens to take out the seemingly "extra" brackets around the "$data" part, they will get a while bunch of rows where all they get is the value true instead of an array. This way, if the user borrows the code but then later on removes the seemingly "extra" brackets, they have something keeping them safe from themselves at least.

I say this because this just happened to some poorly designed code in a system I manage, that as a result caused a whole bunch of blank records to be imported into a database.
----
Server IP: 69.147.83.197
Probable Submitter: 96.53.16.122
----
Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php
Edit        -- https://master.php.net/note/edit/102526
Del: integrated  -- https://master.php.net/note/delete/102526/integrated
Del: useless     -- https://master.php.net/note/delete/102526/useless
Del: bad code    -- https://master.php.net/note/delete/102526/bad+code
Del: spam        -- https://master.php.net/note/delete/102526/spam
Del: non-english -- https://master.php.net/note/delete/102526/non-english
Del: in docs     -- https://master.php.net/note/delete/102526/in+docs
Del: other reasons-- https://master.php.net/note/delete/102526
Reject      -- https://master.php.net/note/reject/102526
Search      -- https://master.php.net/manage/user-notes.php