I was fortunate enough to recently have been allowed to work on a PHP project. I am very experienced with C#. Yet I'm still struggling to make sense of this code snippet. Is this valid PHP? Does it run inside .net? What is public private? (Is it only making the setter private?)
PHP is legitimately pretty great. it’s been my goto language for quick scripts and command line stuff for years. Like any language it can look good or bad. Helped that I came from Perl though
In the PHP project I worked on I did inteoduce PHPStan (static code analysis tool) with an integration into the IDE and brought it up to level 8 (out of 10, the higher the level the stricter the checks). I still prefer other languages, and there were still a few quirks, but it was fine working with it like that, since it ensured that type hints where present basically everywhere and also that variables where used according to the types.
Just keep setting Id until you get it where you want it to be. Being PHP, I recommend avoiding a loop and just hardcode it, preferably over and over across many lines with random indention.
I don't want to know. I don't care, anymore. I won't care about anything ever again. The culmination of millions of years of refinement since Australopithecus afarensis roamed the Pliocene savannahs is a world with websites running on PHP.
40
u/Sacaldur Jun 11 '26
I was fortunate enough to recently have been allowed to work on a PHP project. I am very experienced with C#. Yet I'm still struggling to make sense of this code snippet. Is this valid PHP? Does it run inside .net? What is
public private? (Is it only making the setter private?)And fun fact, it seems like there is a
dotnetclass in PHP in order to interact with .net classes: https://www.php.net/manual/en/class.dotnet.php88
u/mjec Jun 11 '26
It was supposed to be a surprise that PHP 9 ships with the .NET CLR!
31
u/drcforbin Jun 11 '26
Just keep setting
Iduntil you get it where you want it to be. Being PHP, I recommend avoiding a loop and just hardcode it, preferably over and over across many lines with random indention.6
u/bem981 Jun 11 '26
I thought it was c# until I realized it…
11
u/W00GA Jun 11 '26
this looks made up
wtf is a public private
1
u/Effective_Celery_515 Jun 13 '26
Task failed successfully.
1
u/Extreme_Dependent_63 Jun 14 '26
So the Id property is access-modifiers fluid? 🤡
1
u/TheMaleGazer Jun 16 '26
public private?
I don't want to know. I don't care, anymore. I won't care about anything ever again. The culmination of millions of years of refinement since Australopithecus afarensis roamed the Pliocene savannahs is a world with websites running on PHP.
1
u/KeyIllustrious587 Aug 20 '26
why this php looks like cursed java?
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