Suppose there is some kind of web service. He should get some string from the client. It is not special in terms of format, no regular expressions are needed. Generally speaking, it’s not so important whether there are 10 characters or 10 thousand characters.

However, the memory is in any case limited. Accordingly, if you can send a string of unlimited length, in theory it can happen that there is not enough storage space.

I found that you can set a limit in php.ini for a POST request. Then maybe you should not worry about the entered data? If anything, there will be an error.

So how should you do the right thing? Do I need to check for the length of any data obtained before recording?

    1 answer 1

    It depends on where you are going to record them. If the base, then you need to look how much you can write to the column, if 200 characters, then when the line is 250 characters, the excess will be cut off. But if it is important for you that nothing is cut off, then you need to check.