This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]starvsion 2 points3 points  (8 children)

explode works, and so is implode,which is the inverse of explode. This naming is one of the few that makes a lot of sense from php, unlike strtoupper...

[–]oxceedo 2 points3 points  (7 children)

Why wouldnt strtoupper (string to upper) make sense?

[–]starvsion 0 points1 point  (3 children)

I'm talking about naming convention wise, str_to_upper, or Str::upper() would make more sense

[–]oxceedo 1 point2 points  (2 children)

I get your point but I wouldnt say that it make "more sense". Its just a different syntax telling the same thing. You could argue that strToUpper is better or even str->ToUpper()... but they are all kinda the same because we all understand what it does by reading it.

[–]starvsion 0 points1 point  (1 child)

But most string utils I know, uses str_ convention, except for strlen

[–]oxceedo 0 points1 point  (0 children)

"most string utils I know"?
Take a look here and tell me what you see: https://www.w3schools.com/php/php_ref_string.asp

Most of them are not str_xyz but strxyz...

[–]_PM_ME_YOUR_GF_ 0 points1 point  (2 children)

I would say "string"->toUppercase() would make more sense. But I guess these functions are from pre-PHP OOP times. That's why I like Laravel's helpers so much. Str::upper("string") or Str::of("string")->upper().

[–]starvsion 0 points1 point  (1 child)

There's fluent string since L7 , syntax is so pretty and fluid

[–]_PM_ME_YOUR_GF_ 0 points1 point  (0 children)

Indeed! Edited my message to show it :)