News for hackers. Stuff that matters.
Re:Modern PHP by krapp on Sunday March 27, 2022 @11:08AM (#30820802)
PHP got that from Perl AFAIK. Bash does it too, and TCL.
Re:Modern PHP by chubot on Sunday March 27, 2022 @11:43AM (#30821116)
I'm pretty sure that historically shell is the common influence of PHP, Perl, and Tcl.

PHP also inherits shell's here doc syntax, e.g. <<EOF . Not sure if Perl has that.

Actually PHP started out as a bunch of cgi-bin scripts, if I recall. It was very much "a shell for the web".

It kind of annoys me that they all require $ on the left, whereas shell only requires it on the right, which somehow makes more sense to me, e.g.

    a=$b  # shell

    $a = $b  # PHP and I think Perl
Re:Modern PHP by pweezy on Sunday March 27, 2022 @11:49AM (#30821181)
> It kind of annoys me that they all require $ on the left, whereas shell only requires it on the right

Interesting - it makes it look like Bash uses $ to “read” from the variable, while in PHP/Perl $ only indicates that the rest of the symbol _is_ a variable.

Re:Modern PHP by tyingq on Sunday March 27, 2022 @11:51AM (#30821205)
>>PHP also inherits shell's here doc syntax, e.g. <<EOF . Not sure if Perl has that.

It does.

>>It kind of annoys me that they all require $ on the left

Larry Wall says he went that direction to make namespace clashing between $dog, @dog, %dog, and "sub dog {}" (scalar, array, hashtable, function) a non-issue.

http://www.wall.org/~larry/natural.html ("Disambiguation")

Re:Modern PHP by ZeroGravitas on Sunday March 27, 2022 @11:44AM (#30821130)
Ruby also has $ for global variables, which I assume it also got via Perl. And @ for instance variables, and @@ for class variables.
Re:Modern PHP by TylerE on Sunday March 27, 2022 @09:59PM (#30826253)
It's much worse in perl, because it changes based on how you're using it. E.g. an array vs an element of an array.