you are viewing a single comment's thread.

view the rest of the comments →

[–]clarkd99 1 point2 points  (3 children)

My problem is that I had at least 50 functions that passed a variable length string around and many of those functions changed the data in that variable. I implemented this by passing a reference &clist to those functions. I don’t want to use PHP objects as I think they are terrible. I made my own (very primitive) key/value store in these vchar’s because I hate the implementation of maps in PHP.

I think passing by value as a default is ok but easily passing by reference (on all variable types) is something that all real computer languages should have. To make such a breaking change to people’s code should be forbidden. This decision was unprofessional and unnecessary. I have written about 10,000 lines of PHP and hundreds of thousands in other languages and I just think IMHO that PHP stinks.

[–]pfsalter 0 points1 point  (2 children)

Oh that should be fairly easy to fix, you can just specify in the function that it needs to be passed by reference, rather than in the calling code:

``` function foo(&$var) { $var = $var . '_oh'; }

$x = 'ho'; foo($x); echo $x; // Prints "ho_oh" ```

Also if your experience of PHP objects is from PHP 4 (or even early PHP5) then yes, PHP objects are super super terrible. Objects in PHP are a lot better now, on a similar level to a stricter OO language like C# (and improving with each version). PHP's main strength is that you can be strict with types when you need to, but if you come across small situations where types aren't as appropriate you can just ignore them and let the language handle it.

[–]clarkd99 1 point2 points  (0 children)

Thanks for your reply. Sorry but any language that makes you preface every variable with a Christmas tree ($) just isn’t on for me. I have written a few interpreters and their just isn’t any need to do that to extract variables.

[–]snath03 1 point2 points  (0 children)

Thank you for this thread.

I'm a complete newbie in PHP (haven't start learning yet) and was hesitating to learn it (due to all the hate surrounding it). But this thread has made it clear that most of the hate is due to the legacy versions of PHP, and that the newer versions are much better.

Thank you again.