RE: PHP Variables sizes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Nicolas Verhaeghe - White Echo Technologies
> 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.

----------

If the platform is WIMP, I know there is a variable to set somewhere in an
ini in the System32 folder.

Let me know if this is the case, I had this issue in a couple of WAMP
projects.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux