Re: PHP Variables sizes
| From: | Richard Lynch | Date: | Tue, 25 Apr 2006 06:16:53 +0000 |
| Subject: | Re: PHP Variables sizes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-234659@lists.php.net to get a copy of this message | ||
On Sun, April 23, 2006 10:43 pm, David Killen wrote:
> Is there a maximum size for a variable in PHP. A client of mine is
> having problems working with a file of around 4Mb. Not really being a
> php developer I cannot really answer him. To quote him:
>
> We are not uploading excel from ftp. We are reading excel file which
> is
> about 4 MB. In php settings maximum size of any variable is set to 2
> MB so
> this setting has to change. As any file reading in a variable will
> only read
> up to 2 MB and then it will stop.
>
> I wasn't aware of any setting that allows you to change the max
> variable
> size. Can anyone shed any light on this?
As far as I know, there is no limit to the size of a single variable.
The whole script has a limit in php.ini memory_limit
<?php phpinfo();?> will tell you what that is if you can't read php.ini
If it's not possible to alter memory_limit (on a shared server, for
example) you may have to re-structure the application to read only
PART of the file at a time, and deal with it piece-meal.
This clearly will not work for, say, imagecreatefromjpeg()
But for something like ripping through a CSV file and shoving it into
a database, or reading any kind of text file, really, you can (and
should) do it line by line if it's likely to be a "large" file.
If you are running PHP from the command line, note that you can
override php.ini or (in more recent versions) override a specific
setting within php.ini directly from the command line.
php -h
on the command line should make the "how" obvious, and you'll need to
do that to figure out whether you need a whole new php.ini or can
override a single setting anyway.
--
Like Music?
http://l-i-e.com/artists.htm