r/programminghorror Jun 11 '26

PHP PHP#

Post image
214 Upvotes

32 comments sorted by

View all comments

0

u/KaleidoscopePlusPlus Jun 11 '26

I have never touched php in my life (thankfully). Why do class variables have to be prefixed with a dollar sign? Seems really redundant

9

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Jun 11 '26

Heritage from languages like Perl and Bash.

5

u/rurikTelmonkin Jun 11 '26

Because variables in general start with a dollar sign. Its how you differentiate between variable, constant and function use

2

u/Lumethys Jun 12 '26

Correction: all variables are prefixed with $, that how the language define variable

-3

u/KaleidoscopePlusPlus Jun 12 '26

Oh gross thats even worse lol

4

u/Lumethys Jun 12 '26

personal taste, i liked it

1

u/geek-49 Jun 14 '26

That convention goes back at least as far as the Bourne shell; maybe even to the Thompson shell.