3 ms·
What are the messy bits? I know they are there but how is it a mess in your opinion? There seems to be a lot of "PHP is a mess/garabage/whatever else" hyperbol
by welly 8y ago
What are the messy bits? I know they are there but how is it a mess in your opinion?
There seems to be a lot of "PHP is a mess/garabage/whatever else" hyperbole in this thread with no actual explanations why.
- pathartl 8y agoI for one would rather see common utilities move into proper naming and static classing with proper returns. For instance, strpos(string haystack, string needle) will return the position of needle in haystack as an int if found. If not, it returns false. To me, the proper thing in this scenario is to either return an int (even -1 is fine for not found) or throw an exception. There's inconsistencies in typing of what is returned. There's nothing wrong with loose typing, especially in the place that PHP is used. It's just that the PHP API regularly returns not what you'd expect. Throw into the mix that the built in simple-functions are all over the place (https://www.php.net/manual/en/ref.strings.php https://www.php.net/manual/en/ref.strings.php). Seriously, there's str_replace, strpos, and parse_str. These could easily be solved by doing something similar to C#'s naming by changing it to something like String.Replace, String.IndexOf, String.Parse.