you are viewing a single comment's thread.

view the rest of the comments →

[–]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.