Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

homoky's avatar

Varchar max size

Hi,

I want to make sure that I fully understand Schema builder and string max sizes.

If I add column like this:

$table->string('name', 60);

Does this means that I can push 60 characters in UTF-8 to that column?

I read on the stackoverflow that UTF-8 character can have from 1-3 (I guess) bytes. So it means that the name string will contain max 20 characters in some special case?

0 likes
6 replies
RemiC's avatar

You can have up to 255 characters in a varchar field, whichever encoding you use.

bashy's avatar

Yes it's by single characters and the bytes used will change

homoky's avatar

So I am right when in Varchar 60 can be max 20 characters?

bestmomo's avatar

With a varchar(60) you can stock 60 characters.

homoky's avatar

Any type of characters (?,!"+ěšřčýžříá=) bestmomo?

bestmomo's avatar

@homoky Any type with utf8, I just tried with your example with (?,!"+ěšřčýžříá=?,!"+ěšřčýžříá=) in a varchar(30)

But I had to remove the rule max:30 to get it work, so there is something with validation there. With max:30 I am limited to (?,!"+ěšřčýžříá=?,!"+), so only 20 characters for validation.

Please or to participate in this conversation.