How much data can be sent via $_GET - php

How much data can be sent via $_GET in PHP5? Is there a maximum number of variables, string length etc? Thanks in advance.

Although the specification of the HTTP protocol does not specify any maximum length, practical limits are imposed by web browser and server software.

There is no limit defined in the RFC, but browsers limit the URL length (including get variables). IE for instance limits the URL length to 2083 characters, Opera about 4,050, Netscape 6 about 2,000 characters.
A general rule of thumb is, that you shouldnt use more than 256 characters.

There is not only the PHP limitation, but you should also consider 'in between' proxies and the client software.
The http standard doesn't pose a limitation, though.
(I got this from here, where advice is to not exceed 255 char's urls!)

Related

Are apache environment variables ASCII (as reflected in PHP $_SERVER)?

I'm sanitizing USER_AGENT for logging in PHP and need to know whether to use substr() or mb_strcut().
Seeing how USER_AGENT is directly derived from the HTTP request header User-Agent, I'm going to assume you're interested in HTTP headers.
Is it possible that HTTP headers will contain bytes outside the 7-bit ASCII range? Yes.
Is it likely that you'll actually see this in practice and need to handle it properly? I'd say no.
Therefore I suggest a third option: first strip all non-ASCII characters from the string, then use regular multibyte-unsafe functions to your heart's content.

PHP_NORMAL_READ cutting off the data being sent

I need some help please,I have problem in reading the binary data that was sent by the device via socket.I could not receive the exact data that was sent. I am using this code
$data = #socket_read($read_sock,2048,PHP_NORMAL_READ);
I am using PHP_NORMAL_READ because it will stop reading with this "\r\n".
but when I receive,the data is not exact it only receive few binary data.
The length parameter specifies the maximum length that will be read from the stream. The PHP documentation is a bit misguiding on this subject, but what I think it means is, that you will get:
less than or exactly 'length' bytes
at least one byte
no '\r' or '\n' in the response, unless it is the only character
Most of the Socket APIs you encounter work this way, they may give you less bytes than requested, because more bytes may not be available and the data may arrive in smaller parts than that the device sent them in. The solution is to read from the socket repeatedly, until you get what you want (that means until you get string ending with newline, in your case).
You also may want to consult http://php.net/manual/en/function.socket-read.php, where the commenters suggest the functions is somewhat buggy when used with PHP_NORMAL_READ. It might be worth searching for some socket library for PHP that supports readLine.

Max Length For Get Variable

I was wondering if there is a max length on a $_GET variable. I plan on using ajax with a get command and part of it is an encoding of an access key using one of my encoding methods. This method has returned back roughly 1530 characters and I was wondering if this it too long for a get variable as long as it's all URL encoded?
Thanks in advance,
Spencer
Browser would greatly affect the max length of your $_GET param
MAXIMUM LENGTH FOR BROWSERS REFERENCE
Some versions of PHP have a limitation of length of GET params:
PHP.NET REFERENCE
Max URL length is around 2000 charactors
In IE is around 2048 - http://support.microsoft.com/kb/208427
Similar to this? https://stackoverflow.com/a/7725515/2827152
Please note that PHP setups with the suhosin patch installed will have a default limit of 512
characters for get parameters. Although bad practice, most browsers (including IE) supports URLs up
to around 2000 characters, while Apache has a default of 8000.
To add support for long parameters with suhosin, add suhosin.get.max_value_length = in php.ini
Source: http://www.php.net/manual/en/reserved.variables.get.php#101469

What is the maximum URI length in codeigniter?

I'm wandering what the maximum URI length is in codeigniter, and if URI segments being used as arguments to a controller function count towards the browsers GET length limit? I think most browsers cap there GET parameter length to about 2000?
Currently if my total URI length (inc. https://domain/folder/controller/function/argument) exceeds around 1560 characters I get a forbidden message.
'Forbidden You don't have permission to access /folder/controller/function/argument on this server'
If I trim the characters back to under around 1550~1560 it works fine again. I realise 1500+ is alot anyway, which is why I was wandering if URI counts towards the GET limit.
Has anyone experienced this problem? Is there a solution aside from POSTing all data?
BTW: I'm using the URI protocol AUTO in the config
As far as I remember the whole URI is limited to a more or less specific length. Something is already mentioned here: What is the maximum length of a URL in different browsers?
However, it feels a little bit curious, that you require such long uris. If you append a query string of around 1000 characters length, thats already 1kB of data. In my oppinion a query string is not the right place to transport data around.

maximum URI length for file_get_contents()

Is there a maximum length for the URI in the file_get_contents() function in PHP?
I suppose there is a maximum length, but you'll be hard pressed to find it. If you do hit the maximum, you're doing something wrong. :)
I haven't been able to find a number for PHP specifically, but MS IIS, Apache and the Perl HTTP::Daemon seem to have limits between 4,000 and 16,384 bytes, PHP will probably be somewhere around there as well.
What you need to consider is not really how much your side can handle, but also how much the other server you're querying can handle (which is presumably what you're doing). As such, any URL longer than ~1000 characters is usually already way too long and never really encountered in the real world.
As others have stated, it is most likely limited by the HTTP protocol.
You can view this answer for more info on that : What is the maximum length of an url?
In HTTP there's no length-limit for URI,and there's no note of file_get_contents() about this in the manual .So I think you needn't to consider about this problem.
BTW,the length of URI is limited by some browser and webserver.For example,in IE,the length should be less than 2083 and in FF it's 65,536.I tried to test this I found that only not more than 8182 is OK when I visited my apache on ubuntu because of limit of my apache.

Categories