subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
devsnd
2o9ov1
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|eols|><|endoftext|>
47
lolphp
deadstone
cml29yu
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>"Serialize your array and then put it into the constant" "Just want to say I love this solution :)" PHP devs terrify me.<|eor|><|eols|><|endoftext|>
65
lolphp
allthediamonds
cmlc5p9
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>Let me remind you, on PHP, you can redefine constants. Yep, you read that right. http://3v4l.org/XrZNH<|eor|><|eols|><|endoftext|>
22
lolphp
expugnator3000
cml2ate
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>PHPs whole implementation of constants is ridiculous. Call a function and it potentially modifies all code below?<|eor|><|eols|><|endoftext|>
21
lolphp
foobar5678
cml5sjo
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>This was fixed. http://php.net/manual/en/language.constants.syntax.php > From PHP 5.6 onwards, it is also possible to define an array constant.<|eor|><|eols|><|endoftext|>
19
lolphp
catcradle5
cmlz5ej
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>"Serialize your array and then put it into the constant" "Just want to say I love this solution :)" PHP devs terrify me.<|eor|><|sor|>I fucking hate php serialization and every time I have to build data structures with it.<|eor|><|sor|>This strange obsession with serialization in PHP has also led to numerous critical web app vulnerabilities in many large projects and frameworks, like [Wordpress](https://vagosec.org/2013/09/wordpress-php-object-injection/) and [Laravel](https://labs.mwrinfosecurity.com/blog/2014/04/11/laravel-cookie-forgery-decryption-and-rce/), nearly always resulting in arbitrary code execution. Wordpress: >Lets recap: maybe_serialized('i:1;') is inserted to the database. As WordPress does not see this as a serialized string (because it doesnt end in ; or }), this will result in i:1;. When inserted, MySQL doesnt know how to store it properly, and removes the astral symbol . Later on, when the value i:1; is retrieved, it will be unserialized as it now has ; as last character which will make is_serialized() return true. Boom. Vulnerability. Laravel: >We are already making use of unserialize() as the basis of our padding oracle. How about we exploit unserialize() to perform a PHP object injection attack and execute arbitrary code? Check the dates on those writeups, too: 2013 and 2014. This is still the state of PHP today. And that's not to mention the likely countless random hacked-together projects around the web that probably have object injection vulnerabilities as well. If Wordpress and Laravel devs are making these errors, you can sure as hell bet your "average" (relative to PHP) PHP devs are too.<|eor|><|eols|><|endoftext|>
15
lolphp
expugnator3000
cmlhwul
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>Let me remind you, on PHP, you can redefine constants. Yep, you read that right. http://3v4l.org/XrZNH<|eor|><|sor|>Only works until all combinations of upper/lower case letters is used up, so you can redefine constants, but only *a limited number of times* ;)<|eor|><|eols|><|endoftext|>
12
lolphp
nikic
cml841f
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>This was fixed. http://php.net/manual/en/language.constants.syntax.php > From PHP 5.6 onwards, it is also possible to define an array constant.<|eor|><|sor|>Note that this currently only works with `const` declarations and not with `define` - but I think that's just an oversight and we could trivially allow it as well by removing the check for it.<|eor|><|eols|><|endoftext|>
10
lolphp
expugnator3000
cmnadbf
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>Let me remind you, on PHP, you can redefine constants. Yep, you read that right. http://3v4l.org/XrZNH<|eor|><|sor|>Only works until all combinations of upper/lower case letters is used up, so you can redefine constants, but only *a limited number of times* ;)<|eor|><|sor|>I think it's not exactly that... http://3v4l.org/b1hmb<|eor|><|sor|>Every time I think I know how something in PHP works, someone comes along and shows how it is actually even more ridiculous<|eor|><|eols|><|endoftext|>
8
lolphp
edwardly
cmlpsav
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>Let me remind you, on PHP, you can redefine constants. Yep, you read that right. http://3v4l.org/XrZNH<|eor|><|sor|>That's not really redefining, just abusing case insensitivity. If you [really want to](http://i.imgur.com/3eA2qMp.jpg) redefine contants [use runkit.](http://php.net/manual/en/function.runkit-constant-redefine.php)<|eor|><|eols|><|endoftext|>
6
lolphp
allthediamonds
cmnab5b
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>Let me remind you, on PHP, you can redefine constants. Yep, you read that right. http://3v4l.org/XrZNH<|eor|><|sor|>Only works until all combinations of upper/lower case letters is used up, so you can redefine constants, but only *a limited number of times* ;)<|eor|><|sor|>I think it's not exactly that... http://3v4l.org/b1hmb<|eor|><|eols|><|endoftext|>
6
lolphp
allthediamonds
cmpwajc
<|sols|><|sot|>PHP Constants Containing Arrays?<|eot|><|sol|>https://stackoverflow.com/questions/1290318/php-constants-containing-arrays<|eol|><|sor|>Let me remind you, on PHP, you can redefine constants. Yep, you read that right. http://3v4l.org/XrZNH<|eor|><|sor|>You can't redefine constants at all, it's just someone made the godawful decision to allow case-sensitivity on a per-constant basis, and obviously there has to be some order of precedence (insensitive constants before sensitive constants or vice-versa).<|eor|><|sor|>I know you aren't technically redefining anything, but the overshadowing of one constant by another causes the rest of the PHP script to use a different constant, which is functionally indistinguishable from redefining it.<|eor|><|eols|><|endoftext|>
5
lolphp
vytah
2c281s
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|eols|><|endoftext|>
50
lolphp
tdammers
cjbakyr
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|sor|>2005 and still not resolved.. fucking lol > Any efforts by Debian to change that just makes the extension authors "consider us quite strange for even mentioning" a license change. &#3232;_&#3232;<|eor|><|sor|>Except the debian guys are fucking retarded. Rewriting the JSON licence because Douglas Crockford made a funny joke in the licence agreement? Seriously?! Americans aren't as hardcore about "freedom" as the fucking Debian guys.<|eor|><|sor|>It's the kind of technicality that can and does win lawsuits. And the Debian folks are under quite an obligation here; people use the OS for all sorts of things, and they have to be able to rely on the project's assurance that anything in it can actually be used freely. Practically speaking, Doug Crockford isn't going to sue anyone over the license, but who knows what happens when the right kind of lawyers gets his hands on this stuff.<|eor|><|eols|><|endoftext|>
28
lolphp
aleczapka
cjb96xm
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|sor|>2005 and still not resolved.. fucking lol > Any efforts by Debian to change that just makes the extension authors "consider us quite strange for even mentioning" a license change. &#3232;_&#3232;<|eor|><|eols|><|endoftext|>
21
lolphp
rcxdude
cjbbh3q
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|sor|>2005 and still not resolved.. fucking lol > Any efforts by Debian to change that just makes the extension authors "consider us quite strange for even mentioning" a license change. &#3232;_&#3232;<|eor|><|sor|>Except the debian guys are fucking retarded. Rewriting the JSON licence because Douglas Crockford made a funny joke in the licence agreement? Seriously?! Americans aren't as hardcore about "freedom" as the fucking Debian guys.<|eor|><|sor|>legal documents are not the place for jokes.<|eor|><|eols|><|endoftext|>
20
lolphp
tdammers
cjbbzi5
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|sor|>2005 and still not resolved.. fucking lol > Any efforts by Debian to change that just makes the extension authors "consider us quite strange for even mentioning" a license change. &#3232;_&#3232;<|eor|><|sor|>Except the debian guys are fucking retarded. Rewriting the JSON licence because Douglas Crockford made a funny joke in the licence agreement? Seriously?! Americans aren't as hardcore about "freedom" as the fucking Debian guys.<|eor|><|sor|>It's the kind of technicality that can and does win lawsuits. And the Debian folks are under quite an obligation here; people use the OS for all sorts of things, and they have to be able to rely on the project's assurance that anything in it can actually be used freely. Practically speaking, Doug Crockford isn't going to sue anyone over the license, but who knows what happens when the right kind of lawyers gets his hands on this stuff.<|eor|><|sor|>IBM actually has a "special" JSON licence that excludes that clause, which is IMO the "correct" way to do it if someone is truly concerned.<|eor|><|sor|>Yup. It's not very likely that anyone is ever going to challenge the "The Software shall be used for Good, not Evil." part, but you never know with lawyers. They might just have some weird sort of definition of "Good" and "Evil", and you might be violating it for, idk, using JSON as part of a dating site where people come to cheat on their partners or something, idk. Licenses are not the place for being funny.<|eor|><|eols|><|endoftext|>
15
lolphp
mort96
cjbuczq
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|sor|>It could be worse, they could all use GPL licence.<|eor|><|sor|>Why would that be worse? If were using GPL, it could've been used for open source software. However, since the license they have now isn't technically valid, it's technically under full copyright protection, which means nobody can use it for anything.<|eor|><|eols|><|endoftext|>
12
lolphp
vytah
cjb6bz7
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|soopr|>Example from ImageMagick extension: https://github.com/mkoppanen/imagick/blob/master/LICENSE<|eoopr|><|eols|><|endoftext|>
9
lolphp
redalastor
cjbjgby
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|sor|>2005 and still not resolved.. fucking lol > Any efforts by Debian to change that just makes the extension authors "consider us quite strange for even mentioning" a license change. &#3232;_&#3232;<|eor|><|sor|>Except the debian guys are fucking retarded. Rewriting the JSON licence because Douglas Crockford made a funny joke in the licence agreement? Seriously?! Americans aren't as hardcore about "freedom" as the fucking Debian guys.<|eor|><|sor|>It's the kind of technicality that can and does win lawsuits. And the Debian folks are under quite an obligation here; people use the OS for all sorts of things, and they have to be able to rely on the project's assurance that anything in it can actually be used freely. Practically speaking, Doug Crockford isn't going to sue anyone over the license, but who knows what happens when the right kind of lawyers gets his hands on this stuff.<|eor|><|sor|>IBM actually has a "special" JSON licence that excludes that clause, which is IMO the "correct" way to do it if someone is truly concerned.<|eor|><|sor|>Actually, they have an email from Doug that says : "I give permission for IBM, its customers, partners, and minions, to use JSLint for evil."<|eor|><|eols|><|endoftext|>
9
lolphp
gu3st12
cjbasav
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|sor|>2005 and still not resolved.. fucking lol > Any efforts by Debian to change that just makes the extension authors "consider us quite strange for even mentioning" a license change. &#3232;_&#3232;<|eor|><|sor|>Except the debian guys are fucking retarded. Rewriting the JSON licence because Douglas Crockford made a funny joke in the licence agreement? Seriously?! Americans aren't as hardcore about "freedom" as the fucking Debian guys.<|eor|><|sor|>It's the kind of technicality that can and does win lawsuits. And the Debian folks are under quite an obligation here; people use the OS for all sorts of things, and they have to be able to rely on the project's assurance that anything in it can actually be used freely. Practically speaking, Doug Crockford isn't going to sue anyone over the license, but who knows what happens when the right kind of lawyers gets his hands on this stuff.<|eor|><|sor|>IBM actually has a "special" JSON licence that excludes that clause, which is IMO the "correct" way to do it if someone is truly concerned.<|eor|><|eols|><|endoftext|>
8
lolphp
aleczapka
cjbecca
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|sor|>2005 and still not resolved.. fucking lol > Any efforts by Debian to change that just makes the extension authors "consider us quite strange for even mentioning" a license change. &#3232;_&#3232;<|eor|><|sor|>Except the debian guys are fucking retarded. Rewriting the JSON licence because Douglas Crockford made a funny joke in the licence agreement? Seriously?! Americans aren't as hardcore about "freedom" as the fucking Debian guys.<|eor|><|sor|>It's not about being 'hardcore', it's about what's actually legal or what's not. Besides, I don't think they changed the license because they thought Douglas Crockford had a bad sense of humor. They do it because 'the joke' could cost ppl money (internet is full of trolls). but anyways.. why are we bashing debian guys here? this is /r/lolphp !<|eor|><|eols|><|endoftext|>
7
lolphp
mort96
cjc8y5h
<|sols|><|sot|>Several major PHP extensions use PHP license, which formally cannot be applied to anything else but PHP itself<|eot|><|sol|>http://lwn.net/Articles/604630/<|eol|><|sor|>It could be worse, they could all use GPL licence.<|eor|><|sor|>Why would that be worse? If were using GPL, it could've been used for open source software. However, since the license they have now isn't technically valid, it's technically under full copyright protection, which means nobody can use it for anything.<|eor|><|sor|>Because nothing is worse than the GPL. It is cancer. <|eor|><|sor|>Yes, the GPL is a viral license. How's that bad?<|eor|><|sor|>It makes any piece of software that is GPL licenced unsuitable for any use in a larger project because of the cancerous multiplication that the GPL manifests. LGPL is a bit better as it allows you to dynamically link a piece of software without needing to give away all your other hard work. <|eor|><|sor|>It doesn't make it impossible to use for large projects. It makes it impossible for use in projects which aren't free (as in speech), which is a perfectly reasonable requirement. <|eor|><|eols|><|endoftext|>
5
lolphp
abadidea
1pkag5
<|sols|><|sot|>You asked for it - new content. A review of PHP 2.0!<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/post/65544023819/php-2-0-a-review-in-retrospect<|eol|><|eols|><|endoftext|>
46
lolphp
mayobutter
cd3ald6
<|sols|><|sot|>You asked for it - new content. A review of PHP 2.0!<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/post/65544023819/php-2-0-a-review-in-retrospect<|eol|><|sor|>Part of understanding PHP's quirks is realizing where it has come from. Web development was very different back in 1997 (I was there). Back then having GET and POST parameters automatically loaded into global variables was useful, easy, and kind of made sense. PHP has always given web developers exactly what they want, even if those features a couple of years later turn out to be very, very, very bad ideas.<|eor|><|eols|><|endoftext|>
9
lolphp
Sarcastinator
cd3ksl5
<|sols|><|sot|>You asked for it - new content. A review of PHP 2.0!<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/post/65544023819/php-2-0-a-review-in-retrospect<|eol|><|sor|>>> Each PHP instruction starts with `<?` and ends with a `>`. > > Im curious why this later changed, since this isnt necessarily _bad_ per se although I prefer `<? ?>` for obvious visual balance. I imagine this was done to match up with the XML processing instruction syntax. How did the original not clash with the greater-than operator, though?<|eor|><|sor|> <? if($a > $b) > vs <? $c = $a > $b > So i would say it did clash. It just wasn't noticed until later.<|eor|><|eols|><|endoftext|>
8
lolphp
skeeto
cd3atrh
<|sols|><|sot|>You asked for it - new content. A review of PHP 2.0!<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/post/65544023819/php-2-0-a-review-in-retrospect<|eol|><|sor|>It always annoys me how badly PHP misidentifies language concepts. I see from the article the misuse of the word "variable" goes all the way back to 2.0. >> Three types of variables are supported. Long integer, Double precision floating point and character strings. No, *variables* don't have types in PHP, *values* do. These are the three types of primitive values. This misnomer still lives on today in the [poorly-named, incorrectly documented `var_dump()`](http://php.net/manual/en/function.var-dump.php). `var_dump()` doesn't dump variables, or even expressions. It dumps information about values and structures. <|eor|><|eols|><|endoftext|>
7
lolphp
cfreak2399
cd3mq8f
<|sols|><|sot|>You asked for it - new content. A review of PHP 2.0!<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/post/65544023819/php-2-0-a-review-in-retrospect<|eol|><|sor|>Part of understanding PHP's quirks is realizing where it has come from. Web development was very different back in 1997 (I was there). Back then having GET and POST parameters automatically loaded into global variables was useful, easy, and kind of made sense. PHP has always given web developers exactly what they want, even if those features a couple of years later turn out to be very, very, very bad ideas.<|eor|><|sor|>It shouldn't have been different. For example I was writing <script>alert("I hacked you!");</script> into CGI chat rooms around that time. To be fair it took awhile before I became aware of the implications though. <|eor|><|eols|><|endoftext|>
6
lolphp
ealf
16yu8e
<|soss|><|sot|>get_class($foo->member) returns the name of the calling class if member is NULL<|eot|><|sost|> <?php class Box { function getContentType() { return get_class($this->content); } } class Foo { } $x = new Box(); $x->content = new Foo(); echo $x->getContentType(), "\n"; // outputs 'Foo' $x = new Box(); echo $x->getContentType(), "\n"; // outputs 'Box' <|eost|><|eoss|><|endoftext|>
45
lolphp
becauseofreasons
ji0qp0
<|soss|><|sot|>"Argument must be an instance of boolean, boolean given."<|eot|><|sost|>I ended up shoveling piles of PHP a few days ago. I'm not (particularly) new to the language, but I avoid it asmuch as possible. Has there been any kind of explanation for why PHP's static and runtime type systems have two different and exclusive names for booleans? I cannot think of *any* gradually-typed language where using the runtime name of a primitive type (`boolean`) throws a fatal type error when you annotate something with it. The only thing I found in the documentation was "hurr durr, aliases not supported, just works that way." Why is `boolean` an "alias"if it's *literally the name of the type*?!<|eost|><|eoss|><|endoftext|>
44
lolphp
Perdouille
ga59sa0
<|soss|><|sot|>"Argument must be an instance of boolean, boolean given."<|eot|><|sost|>I ended up shoveling piles of PHP a few days ago. I'm not (particularly) new to the language, but I avoid it asmuch as possible. Has there been any kind of explanation for why PHP's static and runtime type systems have two different and exclusive names for booleans? I cannot think of *any* gradually-typed language where using the runtime name of a primitive type (`boolean`) throws a fatal type error when you annotate something with it. The only thing I found in the documentation was "hurr durr, aliases not supported, just works that way." Why is `boolean` an "alias"if it's *literally the name of the type*?!<|eost|><|sor|>In new PHP versions (>= 7.3) the error message is better Fatal error: Uncaught TypeError: Argument 1 passed to x() must be an instance of boolean, bool given And on PHP 8 they added a warning Warning: "boolean" will be interpreted as a class name. Did you mean "bool"? Write "\boolean" to suppress this warning in /in/E71W9 on line 3<|eor|><|eoss|><|endoftext|>
17
lolphp
CarnivorousSociety
ga46ea8
<|soss|><|sot|>"Argument must be an instance of boolean, boolean given."<|eot|><|sost|>I ended up shoveling piles of PHP a few days ago. I'm not (particularly) new to the language, but I avoid it asmuch as possible. Has there been any kind of explanation for why PHP's static and runtime type systems have two different and exclusive names for booleans? I cannot think of *any* gradually-typed language where using the runtime name of a primitive type (`boolean`) throws a fatal type error when you annotate something with it. The only thing I found in the documentation was "hurr durr, aliases not supported, just works that way." Why is `boolean` an "alias"if it's *literally the name of the type*?!<|eost|><|sor|>idk but probably because the type hinting system was added much later and not at inception of the language? not an excuse though, that is odd.<|eor|><|eoss|><|endoftext|>
9
lolphp
bkdotcom
ga4jf62
<|soss|><|sot|>"Argument must be an instance of boolean, boolean given."<|eot|><|sost|>I ended up shoveling piles of PHP a few days ago. I'm not (particularly) new to the language, but I avoid it asmuch as possible. Has there been any kind of explanation for why PHP's static and runtime type systems have two different and exclusive names for booleans? I cannot think of *any* gradually-typed language where using the runtime name of a primitive type (`boolean`) throws a fatal type error when you annotate something with it. The only thing I found in the documentation was "hurr durr, aliases not supported, just works that way." Why is `boolean` an "alias"if it's *literally the name of the type*?!<|eost|><|sor|>idk but probably because the type hinting system was added much later and not at inception of the language? not an excuse though, that is odd.<|eor|><|sor|>Yes... let's consult the manual. > Warning Aliases for the above scalar types are not supported. Instead, they are treated as class or interface names. For example, using boolean as a parameter or return type will require an argument or return value that is an instanceof the class or interface boolean, rather than of type bool: This seems to be more of a documentation issue with scalar types. https://www.php.net/manual/en/language.types.intro.php<|eor|><|eoss|><|endoftext|>
9
lolphp
Perdouille
ga5m0ep
<|soss|><|sot|>"Argument must be an instance of boolean, boolean given."<|eot|><|sost|>I ended up shoveling piles of PHP a few days ago. I'm not (particularly) new to the language, but I avoid it asmuch as possible. Has there been any kind of explanation for why PHP's static and runtime type systems have two different and exclusive names for booleans? I cannot think of *any* gradually-typed language where using the runtime name of a primitive type (`boolean`) throws a fatal type error when you annotate something with it. The only thing I found in the documentation was "hurr durr, aliases not supported, just works that way." Why is `boolean` an "alias"if it's *literally the name of the type*?!<|eost|><|sor|>In new PHP versions (>= 7.3) the error message is better Fatal error: Uncaught TypeError: Argument 1 passed to x() must be an instance of boolean, bool given And on PHP 8 they added a warning Warning: "boolean" will be interpreted as a class name. Did you mean "bool"? Write "\boolean" to suppress this warning in /in/E71W9 on line 3<|eor|><|sor|>what kind of sick mofo would make a `class Boolean{...}` ?<|eor|><|sor|>idk, but I could see it happen For example you have a "Form" namespace with some kind of FormBuilder, you could have Form\Boolean for building checkboxes ?<|eor|><|eoss|><|endoftext|>
9
lolphp
becauseofreasons
ga5so1m
<|soss|><|sot|>"Argument must be an instance of boolean, boolean given."<|eot|><|sost|>I ended up shoveling piles of PHP a few days ago. I'm not (particularly) new to the language, but I avoid it asmuch as possible. Has there been any kind of explanation for why PHP's static and runtime type systems have two different and exclusive names for booleans? I cannot think of *any* gradually-typed language where using the runtime name of a primitive type (`boolean`) throws a fatal type error when you annotate something with it. The only thing I found in the documentation was "hurr durr, aliases not supported, just works that way." Why is `boolean` an "alias"if it's *literally the name of the type*?!<|eost|><|soopr|>For the "read the manual/error messages" folksI frankly don't care that the error message is stupid, and haven't claimed that the documentation doesn't cover it. The *behavior* is stupid. And you can document/clarify stupidityuntil you pass out, but that doesn't make it any less stupid.<|eoopr|><|eoss|><|endoftext|>
7
lolphp
Flerex
ga5am24
<|soss|><|sot|>"Argument must be an instance of boolean, boolean given."<|eot|><|sost|>I ended up shoveling piles of PHP a few days ago. I'm not (particularly) new to the language, but I avoid it asmuch as possible. Has there been any kind of explanation for why PHP's static and runtime type systems have two different and exclusive names for booleans? I cannot think of *any* gradually-typed language where using the runtime name of a primitive type (`boolean`) throws a fatal type error when you annotate something with it. The only thing I found in the documentation was "hurr durr, aliases not supported, just works that way." Why is `boolean` an "alias"if it's *literally the name of the type*?!<|eost|><|sor|>Its because is the php way. Broken by design. Every corner of PHP is full of warts, the more you use it the more you hate it.<|eor|><|sor|>You must be new at programming. I am yet to find a language that I dont hate. <|eor|><|eoss|><|endoftext|>
5
lolphp
Takeoded
e7ud7r
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|eols|><|endoftext|>
42
lolphp
Takeoded
fa5kush
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|soopr|>running php7 instead of php5? doesn't matter, we're checking "C:\\php5\\" running php on the D:\\ drive instead of the C:\\ drive? doesn't matter, we're checking "C:\\php5\\" [https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr\_mjwp5yov3V1s8wvgro1\_400.gifv](https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr_mjwp5yov3V1s8wvgro1_400.gifv)<|eoopr|><|eols|><|endoftext|>
21
lolphp
Altreus
fa5lrik
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|soopr|>running php7 instead of php5? doesn't matter, we're checking "C:\\php5\\" running php on the D:\\ drive instead of the C:\\ drive? doesn't matter, we're checking "C:\\php5\\" [https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr\_mjwp5yov3V1s8wvgro1\_400.gifv](https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr_mjwp5yov3V1s8wvgro1_400.gifv)<|eoopr|><|sor|>Running PHP on a Windows system? Running with scissors in a knife factory.<|eor|><|eols|><|endoftext|>
18
lolphp
BufferUnderpants
fa5w0a7
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|soopr|>running php7 instead of php5? doesn't matter, we're checking "C:\\php5\\" running php on the D:\\ drive instead of the C:\\ drive? doesn't matter, we're checking "C:\\php5\\" [https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr\_mjwp5yov3V1s8wvgro1\_400.gifv](https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr_mjwp5yov3V1s8wvgro1_400.gifv)<|eoopr|><|sor|>Running PHP on a Windows system? Running with scissors in a knife factory.<|eor|><|soopr|>well [https://i.imgur.com/VKnEQ3r.png](https://i.imgur.com/VKnEQ3r.png)<|eoopr|><|sor|>I think you blew it by running PHP 7. Totally ruins the immersive retro feel of running Cygwin on Windows 7.<|eor|><|eols|><|endoftext|>
14
lolphp
Miserable_Fuck
fa7t7r8
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|sor|>> The directory where the extension is loaded from depends on your platform: > >Windows - If not explicitly set in the php.ini, the extension is loaded from C:\php5\ by default. Is it too difficult to change an `ini` setting!<|eor|><|sor|>Not as difficult as not providing a retarded default, apparently<|eor|><|eols|><|endoftext|>
13
lolphp
mrexodia
fa5ox4k
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|soopr|>running php7 instead of php5? doesn't matter, we're checking "C:\\php5\\" running php on the D:\\ drive instead of the C:\\ drive? doesn't matter, we're checking "C:\\php5\\" [https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr\_mjwp5yov3V1s8wvgro1\_400.gifv](https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr_mjwp5yov3V1s8wvgro1_400.gifv)<|eoopr|><|sor|>To be honest the Windows behaviour is at least simple (if not a bit stupid). The unix behaviour is way more complicated (and just as hardcoded).<|eor|><|eols|><|endoftext|>
10
lolphp
nsfwIvan
fa9qf6k
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|sor|>> The directory where the extension is loaded from depends on your platform: > >Windows - If not explicitly set in the php.ini, the extension is loaded from C:\php5\ by default. Is it too difficult to change an `ini` setting!<|eor|><|sor|>Not as difficult as not providing a retarded default, apparently<|eor|><|sor|>And what would a not retarded default be ? It's not like PHP has a "i_was_installed_in_this_directory" env variable, like the JAVA_HOME.<|eor|><|sor|>How about "the directory the PHP binary is in" given how everything else is also bound to be there, usually<|eor|><|sor|>But this information isn't available anywhere. On Linux, you could use locate or whereis, but it would need a system call at each use of the dl() function, **and** for locate or whereis to be installed and executable by the php user. I don't know any similar feature on Windows. IMHO, the correct behavior should be no default value, and throw an error if the function is used without the correct php.in parameter set (you already have a warning if you don't set the timezone properly, so this would be coherent).<|eor|><|sor|>You should take a look at https://www.php.net/manual/en/reserved.constants.php Keyword PHP_BINDIR and PHP_BINARY<|eor|><|eols|><|endoftext|>
8
lolphp
SaltineAmerican_1970
fa6oxc6
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|sor|>> The directory where the extension is loaded from depends on your platform: > >Windows - If not explicitly set in the php.ini, the extension is loaded from C:\php5\ by default. Is it too difficult to change an `ini` setting!<|eor|><|eols|><|endoftext|>
7
lolphp
Takeoded
fa5mvs8
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|soopr|>running php7 instead of php5? doesn't matter, we're checking "C:\\php5\\" running php on the D:\\ drive instead of the C:\\ drive? doesn't matter, we're checking "C:\\php5\\" [https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr\_mjwp5yov3V1s8wvgro1\_400.gifv](https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr_mjwp5yov3V1s8wvgro1_400.gifv)<|eoopr|><|sor|>Running PHP on a Windows system? Running with scissors in a knife factory.<|eor|><|soopr|>well [https://i.imgur.com/VKnEQ3r.png](https://i.imgur.com/VKnEQ3r.png)<|eoopr|><|eols|><|endoftext|>
7
lolphp
nsfwIvan
fadb284
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|sor|>> The directory where the extension is loaded from depends on your platform: > >Windows - If not explicitly set in the php.ini, the extension is loaded from C:\php5\ by default. Is it too difficult to change an `ini` setting!<|eor|><|sor|>Not as difficult as not providing a retarded default, apparently<|eor|><|sor|>And what would a not retarded default be ? It's not like PHP has a "i_was_installed_in_this_directory" env variable, like the JAVA_HOME.<|eor|><|sor|>How about "the directory the PHP binary is in" given how everything else is also bound to be there, usually<|eor|><|sor|>But this information isn't available anywhere. On Linux, you could use locate or whereis, but it would need a system call at each use of the dl() function, **and** for locate or whereis to be installed and executable by the php user. I don't know any similar feature on Windows. IMHO, the correct behavior should be no default value, and throw an error if the function is used without the correct php.in parameter set (you already have a warning if you don't set the timezone properly, so this would be coherent).<|eor|><|sor|>You should take a look at https://www.php.net/manual/en/reserved.constants.php Keyword PHP_BINDIR and PHP_BINARY<|eor|><|sor|>In that case, why not using PHP_LIBDIR directly, since the dl function loads libraries ?<|eor|><|sor|>Yes, why not. You bought up the issue it's impissible to know where php is installed at runtime.<|eor|><|eols|><|endoftext|>
6
lolphp
Aqiad
fa8bcga
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|soopr|>running php7 instead of php5? doesn't matter, we're checking "C:\\php5\\" running php on the D:\\ drive instead of the C:\\ drive? doesn't matter, we're checking "C:\\php5\\" [https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr\_mjwp5yov3V1s8wvgro1\_400.gifv](https://66.media.tumblr.com/e21db7234373895d851b44bc0821f2c1/tumblr_mjwp5yov3V1s8wvgro1_400.gifv)<|eoopr|><|sor|>>running php7 instead of php5? The `dl()` function was removed from FPM in PHP 7.<|eor|><|eols|><|endoftext|>
5
lolphp
eMZi0767
fa9epjz
<|sols|><|sot|>dl( ) default directory is... hardcoded to "C:\php5\"<|eot|><|sol|>https://www.php.net/manual/en/function.dl.php<|eol|><|sor|>> The directory where the extension is loaded from depends on your platform: > >Windows - If not explicitly set in the php.ini, the extension is loaded from C:\php5\ by default. Is it too difficult to change an `ini` setting!<|eor|><|sor|>Not as difficult as not providing a retarded default, apparently<|eor|><|sor|>And what would a not retarded default be ? It's not like PHP has a "i_was_installed_in_this_directory" env variable, like the JAVA_HOME.<|eor|><|sor|>How about "the directory the PHP binary is in" given how everything else is also bound to be there, usually<|eor|><|eols|><|endoftext|>
5
lolphp
pingpong
8msh8r
<|sols|><|sot|>Compute exponents easily with this one weird trick!<|eot|><|sol|>https://3v4l.org/QdXOv<|eol|><|eols|><|endoftext|>
45
lolphp
pingpong
dzpzfh9
<|sols|><|sot|>Compute exponents easily with this one weird trick!<|eot|><|sol|>https://3v4l.org/QdXOv<|eol|><|soopr|>If you're computing 2^n, you need *n + 1* dollar signs.<|eoopr|><|eols|><|endoftext|>
21
lolphp
pingpong
dzq0wxd
<|sols|><|sot|>Compute exponents easily with this one weird trick!<|eot|><|sol|>https://3v4l.org/QdXOv<|eol|><|sor|>That's... quite something. How does it work?<|eor|><|soopr|>I realized after I posted this that it could be [simplified somewhat](https://3v4l.org/ZGVbt), so I'll talk about this one instead of what I originally posted. One of the lols of PHP is that you can use pretty much anything as a variable name, including texts with spaces and newlines, or, in this case, numbers. You just need to use curly braces (`${"1234\n "} = 1; echo ${"1234\n "};`) or variable variables (`$a = "1234\n "; $$a = 1; echo $$a;`). The program is just doing a longer version of something like this <?php ${1} = 2; ${2} = 4; ${4} = 8; echo $$${1}.PHP_EOL; //8<|eoopr|><|eols|><|endoftext|>
20
lolphp
creativeMan
dzq02ho
<|sols|><|sot|>Compute exponents easily with this one weird trick!<|eot|><|sol|>https://3v4l.org/QdXOv<|eol|><|sor|>That's... quite something. How does it work?<|eor|><|sor|>Don't you mean *why* does it work?<|eor|><|eols|><|endoftext|>
14
lolphp
pingpong
dzq1ypn
<|sols|><|sot|>Compute exponents easily with this one weird trick!<|eot|><|sol|>https://3v4l.org/QdXOv<|eol|><|sor|>a) wtf is this b) how do you even find something like this<|eor|><|soopr|>>a) wtf is this Computing 2^1000 with variable variables, explanation [here](https://www.reddit.com/r/lolphp/comments/8msh8r/compute_exponents_easily_with_this_one_weird_trick/dzq0wxd/?context=2) >b) how do you even find something like this I was reading about [T_PAAMAYIM_NEKUDOTAYIM](https://www.reddit.com/r/PHP/comments/1m26z1/t_paamayim_nekudotayim_v_sanity/) and started messing around<|eoopr|><|eols|><|endoftext|>
12
lolphp
fell_ratio
dzpzv3u
<|sols|><|sot|>Compute exponents easily with this one weird trick!<|eot|><|sol|>https://3v4l.org/QdXOv<|eol|><|sor|>That's... quite something. How does it work?<|eor|><|eols|><|endoftext|>
11
lolphp
Xymanek
dzq11zh
<|sols|><|sot|>Compute exponents easily with this one weird trick!<|eot|><|sol|>https://3v4l.org/QdXOv<|eol|><|sor|>a) wtf is this b) how do you even find something like this<|eor|><|eols|><|endoftext|>
10
lolphp
masklinn
e0bwsgx
<|sols|><|sot|>Compute exponents easily with this one weird trick!<|eot|><|sol|>https://3v4l.org/QdXOv<|eol|><|sor|>That's... quite something. How does it work?<|eor|><|soopr|>I realized after I posted this that it could be [simplified somewhat](https://3v4l.org/ZGVbt), so I'll talk about this one instead of what I originally posted. One of the lols of PHP is that you can use pretty much anything as a variable name, including texts with spaces and newlines, or, in this case, numbers. You just need to use curly braces (`${"1234\n "} = 1; echo ${"1234\n "};`) or variable variables (`$a = "1234\n "; $$a = 1; echo $$a;`). The program is just doing a longer version of something like this <?php ${1} = 2; ${2} = 4; ${4} = 8; echo $$${1}.PHP_EOL; //8<|eoopr|><|sor|>I had no idea you could set numeric variables like that. I guess it's never useful, but it's interesting that it's there.<|eor|><|sor|>You can use this feature for even worse things: if you use the "braced" variable reference, the variable "name" is computed, and can be an arbitrary expression. And stacking on the $s basically creates implicit computations using the previous (inner) expression as name so $$t is basically ${${"t"}} aka get the value of the variable whose name is the value of the variable whose name is "t". And it also works with method names because why the fuck would it not work? So you can write shit like `${${$foo.$bar}->${((rand() / getrandmax()) < 0.9) ? $qux : ${$quux($corge)}}()}`<|eor|><|eols|><|endoftext|>
8
lolphp
Dr_Legacy
dzqdxly
<|sols|><|sot|>Compute exponents easily with this one weird trick!<|eot|><|sol|>https://3v4l.org/QdXOv<|eol|><|sor|>That's... quite something. How does it work?<|eor|><|sor|>Don't you mean *why* does it work?<|eor|><|sor|>Don't you mean why *should* it work?<|eor|><|eols|><|endoftext|>
7
lolphp
pilif
4u3fa9
<|sols|><|sot|>Fun with the realpath cache. Apparently touch('/tmp/file') is different from touch('file:///tmp/file')<|eot|><|sol|>https://3v4l.org/0VQIo<|eol|><|eols|><|endoftext|>
45
lolphp
pilif
d5ms7jj
<|sols|><|sot|>Fun with the realpath cache. Apparently touch('/tmp/file') is different from touch('file:///tmp/file')<|eot|><|sol|>https://3v4l.org/0VQIo<|eol|><|sor|>That's fascinating. So `file://` is a separate code path from unmarked path access? I bet there's a ton of edge cases like this, then.<|eor|><|soopr|>file:// goes via the stream wrappers. And metadata changes to those do invalidate the stat cache. For the legacy paths, only rename, rmdir and unlink invalidate the cache. Source: I checked the source code after seeing this happen. <|eoopr|><|eols|><|endoftext|>
16
lolphp
the_alias_of_andrea
d5moti7
<|sols|><|sot|>Fun with the realpath cache. Apparently touch('/tmp/file') is different from touch('file:///tmp/file')<|eot|><|sol|>https://3v4l.org/0VQIo<|eol|><|sor|>That's fascinating. So `file://` is a separate code path from unmarked path access? I bet there's a ton of edge cases like this, then.<|eor|><|eols|><|endoftext|>
13
lolphp
pilif
d5ms88p
<|sols|><|sot|>Fun with the realpath cache. Apparently touch('/tmp/file') is different from touch('file:///tmp/file')<|eot|><|sol|>https://3v4l.org/0VQIo<|eol|><|sor|>How did you come across this?<|eor|><|soopr|>Ran into this while writing a unit test that was checking the mtime of a file. <|eoopr|><|eols|><|endoftext|>
10
lolphp
adbmal
d5mpfb7
<|sols|><|sot|>Fun with the realpath cache. Apparently touch('/tmp/file') is different from touch('file:///tmp/file')<|eot|><|sol|>https://3v4l.org/0VQIo<|eol|><|sor|>How did you come across this?<|eor|><|eols|><|endoftext|>
9
lolphp
cbraga
39h72j
<|sols|><|sot|>So it's 2015 and there's still a tenfold performance improvement to be unlocked from PHP by using compiled bytecode which this guy did by basically creating a php/python converter.<|eot|><|sol|>http://hippyvm.com/<|eol|><|eols|><|endoftext|>
45
lolphp
masklinn
cs47qjl
<|sols|><|sot|>So it's 2015 and there's still a tenfold performance improvement to be unlocked from PHP by using compiled bytecode which this guy did by basically creating a php/python converter.<|eot|><|sol|>http://hippyvm.com/<|eol|><|sor|>Hippy is *not* a "php to python converter", it's a PHP VM built with the same underlying technology Pypy uses (namely rpython, a restricted subset of python specifically for building VMs). And it's not a single guy, though Maciej Fijakowski is the Hippy lead the "About" section lists 7, and it builds on top of the Pypy/rpython project/tech whose list of contributors is [fairly massive](https://bitbucket.org/pypy/pypy/src/tip/LICENSE)<|eor|><|eols|><|endoftext|>
29
lolphp
epsy
cs3fk1t
<|sols|><|sot|>So it's 2015 and there's still a tenfold performance improvement to be unlocked from PHP by using compiled bytecode which this guy did by basically creating a php/python converter.<|eot|><|sol|>http://hippyvm.com/<|eol|><|sor|>PHP 7 has a JIT compiler and a improved lexer/parser which brings huge speed increases to PHP.<|eor|><|sor|>So it's webscale then?<|eor|><|eols|><|endoftext|>
20
lolphp
bart2019
cs3grem
<|sols|><|sot|>So it's 2015 and there's still a tenfold performance improvement to be unlocked from PHP by using compiled bytecode which this guy did by basically creating a php/python converter.<|eot|><|sol|>http://hippyvm.com/<|eol|><|sor|>>At present it does not include a reasonable web server integration, so it's not usable for use in production in the current form. Uh, wait. Isn't that just the main selling point of PHP? So WtF are these guys boasting about?<|eor|><|eols|><|endoftext|>
19
lolphp
gu3st12
cs3c79x
<|sols|><|sot|>So it's 2015 and there's still a tenfold performance improvement to be unlocked from PHP by using compiled bytecode which this guy did by basically creating a php/python converter.<|eot|><|sol|>http://hippyvm.com/<|eol|><|sor|>PHP 7 has a JIT compiler and a improved lexer/parser which brings huge speed increases to PHP.<|eor|><|eols|><|endoftext|>
19
lolphp
vytah
cs3ri4f
<|sols|><|sot|>So it's 2015 and there's still a tenfold performance improvement to be unlocked from PHP by using compiled bytecode which this guy did by basically creating a php/python converter.<|eot|><|sol|>http://hippyvm.com/<|eol|><|sor|>PHP 7 has a JIT compiler and a improved lexer/parser which brings huge speed increases to PHP.<|eor|><|sor|>So it's webscale then?<|eor|><|sor|>Only if you use MongoDB.<|eor|><|eols|><|endoftext|>
19
lolphp
nikic
cs4jj3j
<|sols|><|sot|>So it's 2015 and there's still a tenfold performance improvement to be unlocked from PHP by using compiled bytecode which this guy did by basically creating a php/python converter.<|eot|><|sol|>http://hippyvm.com/<|eol|><|sor|>For those not familiar with language development, it is trivial to get C level (and faster) performance on microbenchmarks with a simple JIT compiler - this applies to all programming languages. However being able to generate fibonacci numbers and mandelbrot sets quickly does not necessarily translate to any significant speedup on real applications. Get back to me when you have that 10x improvement running WP.<|eor|><|eols|><|endoftext|>
9
lolphp
nikic
cs4jd8f
<|sols|><|sot|>So it's 2015 and there's still a tenfold performance improvement to be unlocked from PHP by using compiled bytecode which this guy did by basically creating a php/python converter.<|eot|><|sol|>http://hippyvm.com/<|eol|><|sor|>PHP 7 has a JIT compiler and a improved lexer/parser which brings huge speed increases to PHP.<|eor|><|sor|>PHP 7 has no JIT compiler. The rest is true, although parser improvements and speed increases have (nearly) nothing to do with each other.<|eor|><|eols|><|endoftext|>
9
lolphp
nikic
cs73ddy
<|sols|><|sot|>So it's 2015 and there's still a tenfold performance improvement to be unlocked from PHP by using compiled bytecode which this guy did by basically creating a php/python converter.<|eot|><|sol|>http://hippyvm.com/<|eol|><|sor|>For those not familiar with language development, it is trivial to get C level (and faster) performance on microbenchmarks with a simple JIT compiler - this applies to all programming languages. However being able to generate fibonacci numbers and mandelbrot sets quickly does not necessarily translate to any significant speedup on real applications. Get back to me when you have that 10x improvement running WP.<|eor|><|sor|>It is not just "a simple JIT compiler". http://speed.pypy.org/ http://tratt.net/laurie/blog/entries/fast_enough_vms_in_fast_enough_time If anybody can get that 10x improvement, it'll be these guys.<|eor|><|sor|>Oh, by no means do I mean to imply that pypy and the rpython toolchain in general are anything short of amazing. I was merely suggesting that the presented benchmarks are by no means representative of the performance improvements running real applications and that good performance on microbenchmarks can be trivially reached with a JIT compiler of lower sophistication, thus making their use as the baseline metric rather meaningless. As such this response was directed at the overly sensationalist title of this submission, rather than the linked project itself.<|eor|><|eols|><|endoftext|>
9
lolphp
Laugarhraun
2et0rb
<|sols|><|sot|>In 2008, I bought a "PHP 6" book. Six years later, PHP version is 5.5<|eot|><|sol|>http://modeling-languages.com/2008-bought-book-titled-php-6-six-years-later-php-version-5-5/<|eol|><|eols|><|endoftext|>
46
lolphp
hex_m_hell
ck2wpuz
<|sols|><|sot|>In 2008, I bought a "PHP 6" book. Six years later, PHP version is 5.5<|eot|><|sol|>http://modeling-languages.com/2008-bought-book-titled-php-6-six-years-later-php-version-5-5/<|eol|><|sor|>PHP 6 was a failed experiment. Get over it.<|eor|><|sor|>>PHP was a failed experiment. Get over it. <|eor|><|eols|><|endoftext|>
33
lolphp
bart2019
ck2on6f
<|sols|><|sot|>In 2008, I bought a "PHP 6" book. Six years later, PHP version is 5.5<|eot|><|sol|>http://modeling-languages.com/2008-bought-book-titled-php-6-six-years-later-php-version-5-5/<|eol|><|sor|>PHP 6 was a failed experiment. Get over it.<|eor|><|eols|><|endoftext|>
16
lolphp
softmodeling
ck2zog2
<|sols|><|sot|>In 2008, I bought a "PHP 6" book. Six years later, PHP version is 5.5<|eot|><|sol|>http://modeling-languages.com/2008-bought-book-titled-php-6-six-years-later-php-version-5-5/<|eol|><|sor|>[I think you mean 5.6.](http://php.net/archive/2014.php#id2014-08-28-1)<|eor|><|sor|>The post was written yesterday so technically it was still 5.5 (anyway, this does not change anything, if at all, it makes the situation even worse)<|eor|><|eols|><|endoftext|>
7
lolphp
ealf
xzjg3
<|sols|><|sot|>PHP can't decode JSON. _ takes a flag to choose one of two embedding schemes. One silently turns empty objects into empty lists, the other replaces "" with "_empty_".<|eot|><|sol|>http://codepad.org/Rh3tAKnZ<|eol|><|eols|><|endoftext|>
45
lolphp
Pat55word
c5qyuks
<|sols|><|sot|>PHP can't decode JSON. _ takes a flag to choose one of two embedding schemes. One silently turns empty objects into empty lists, the other replaces "" with "_empty_".<|eot|><|sol|>http://codepad.org/Rh3tAKnZ<|eol|><|sor|>Try $d = json_encode(json_decode($a, maybe)); which merges b and c.<|eor|><|eols|><|endoftext|>
8
lolphp
Altreus
c5rb113
<|sols|><|sot|>PHP can't decode JSON. _ takes a flag to choose one of two embedding schemes. One silently turns empty objects into empty lists, the other replaces "" with "_empty_".<|eot|><|sol|>http://codepad.org/Rh3tAKnZ<|eol|><|sor|>This is why arrays and hashes are different things, kids - you can't tell which you have when it's empty otherwise<|eor|><|eols|><|endoftext|>
6
lolphp
ZorbaTHut
c5rfxee
<|sols|><|sot|>PHP can't decode JSON. _ takes a flag to choose one of two embedding schemes. One silently turns empty objects into empty lists, the other replaces "" with "_empty_".<|eot|><|sol|>http://codepad.org/Rh3tAKnZ<|eol|><|sor|>Try $d = json_encode(json_decode($a, maybe)); which merges b and c.<|eor|><|sor|>Other things to try would be the "kinda", "sorta", and "onceinawhilebutnottoomuch" flags.<|eor|><|eols|><|endoftext|>
5
lolphp
shitcanz
pk534b
<|sols|><|sot|>SQL injection still going strong in 2021<|eot|><|sol|>https://wiki.php.net/rfc/is_literal<|eol|><|eols|><|endoftext|>
42
lolphp
Targren
hc16dpv
<|sols|><|sot|>SQL injection still going strong in 2021<|eot|><|sol|>https://wiki.php.net/rfc/is_literal<|eol|><|sor|>An RFC still using real_escape_string instead of parametric binding is the real LOL.<|eor|><|eols|><|endoftext|>
29
lolphp
JiminP
hc1aiyy
<|sols|><|sot|>SQL injection still going strong in 2021<|eot|><|sol|>https://wiki.php.net/rfc/is_literal<|eol|><|sor|>Thank god the RFC's been rejected.<|eor|><|eols|><|endoftext|>
19
lolphp
Takeoded
he2gpi9
<|sols|><|sot|>SQL injection still going strong in 2021<|eot|><|sol|>https://wiki.php.net/rfc/is_literal<|eol|><|sor|>in b4 <?php /* make a any string pass is_literal, for libraries that require you to use literals.. */ function make_string_literal(string $str):string{ $f=tmpfile(); fwrite($f,'<?php return '.var_export($str,true)); $ret=require(stream_get_meta_data($f)['uri']); fclose($f); return $ret; }<|eor|><|eols|><|endoftext|>
12
lolphp
colshrapnel
hc1dfgv
<|sols|><|sot|>SQL injection still going strong in 2021<|eot|><|sol|>https://wiki.php.net/rfc/is_literal<|eol|><|sor|>All thanks to horrible tutorials that flooded the Net.<|eor|><|eols|><|endoftext|>
10
lolphp
SanityInAnarchy
hlrj7cy
<|sols|><|sot|>SQL injection still going strong in 2021<|eot|><|sol|>https://wiki.php.net/rfc/is_literal<|eol|><|sor|>This feature is very useful for correctness and safety; I guess I shouldn't be surprised PHP rejected it. (I remember doing this in Java (with the obvious ugly hack) in 2005, and it was so useful I eventually learned just enough ocaml to get support for it into Hack.)<|eor|><|sor|>This feature is zero percent useful. Assume all data is tainted and act accordingly.<|eor|><|sor|>Data provided by the developer as a string literal in your actual source code can be assumed safe. If it can't, you have bigger problems than SQL injection. This isn't at all unique to PHP -- it exists in other languages, and it's actually been reasonably successful there.<|eor|><|sor|>Assume everything is tainted and act accordingly. Developers are not infallible and assuming they are is a good way to blow up your entire db.<|eor|><|sor|>If *everything* is tainted, then 'tainted' has no meaning. Is your actual query string tainted? Because that's what this is about: Require the query string to be a literal or entirely derived from literals (so, hardcoded), and require user data to go in bind variables. How does this work in your "assume everything is tainted" world? My code has `SELECT 1` hardcoded somewhere, but you assume that's tainted... so what do you actually do about it, short of just cutting off all DB access? Obviously your developers aren't infallible, but if they're the only ones who can blow up your DB, that's a huge step up over standard SQL injection, and a very far cry from *zero* percent useful.<|eor|><|eols|><|endoftext|>
5
lolphp
Takeoded
hv9vwq
<|sols|><|sot|>echo true; prints 1, echo false; prints nothing, because if it printed 0, it would be consistent.<|eot|><|sol|>https://3v4l.org/aPZ9B<|eol|><|eols|><|endoftext|>
43
lolphp
y0y
fyueswx
<|sols|><|sot|>echo true; prints 1, echo false; prints nothing, because if it printed 0, it would be consistent.<|eot|><|sol|>https://3v4l.org/aPZ9B<|eol|><|sor|>PHP is the clusterfuck of programming languages<|eor|><|sor|>Have you heard of the language brainfuck? <|eor|><|sor|>Brainfuck is perfectly consistent.<|eor|><|eols|><|endoftext|>
13
lolphp
duskwuff
fysp03w
<|sols|><|sot|>echo true; prints 1, echo false; prints nothing, because if it printed 0, it would be consistent.<|eot|><|sol|>https://3v4l.org/aPZ9B<|eol|><|sor|>Here's a clearer demonstration of what's going on: https://3v4l.org/ZLHTZ Both `""` and `"0"` cast back to boolean false, so I'm ambivalent on this one. (I'd personally prefer that all non-empty strings were true, but that's not a battle I'd expect to win.)<|eor|><|eols|><|endoftext|>
11
lolphp
tobb10001
fytf1pt
<|sols|><|sot|>echo true; prints 1, echo false; prints nothing, because if it printed 0, it would be consistent.<|eot|><|sol|>https://3v4l.org/aPZ9B<|eol|><|sor|>This pisses me off every time I try to output something to debug. That's why I've switched to `echo ($var) ? 'true' : 'false';` Thinking about it `var_dump()` might even be handier, but till I think this far the other version is already typed...<|eor|><|eols|><|endoftext|>
7
lolphp
smegnose
fytze30
<|sols|><|sot|>echo true; prints 1, echo false; prints nothing, because if it printed 0, it would be consistent.<|eot|><|sol|>https://3v4l.org/aPZ9B<|eol|><|sor|>This pisses me off every time I try to output something to debug. That's why I've switched to `echo ($var) ? 'true' : 'false';` Thinking about it `var_dump()` might even be handier, but till I think this far the other version is already typed...<|eor|><|sor|>Do you still use `alert()` when debugging JS? Use XDebug.<|eor|><|eols|><|endoftext|>
5
lolphp
postmodest
fyx8yrq
<|sols|><|sot|>echo true; prints 1, echo false; prints nothing, because if it printed 0, it would be consistent.<|eot|><|sol|>https://3v4l.org/aPZ9B<|eol|><|sor|>This pisses me off every time I try to output something to debug. That's why I've switched to `echo ($var) ? 'true' : 'false';` Thinking about it `var_dump()` might even be handier, but till I think this far the other version is already typed...<|eor|><|sor|>Do you still use `alert()` when debugging JS? Use XDebug.<|eor|><|sor|>I love entering the debugger for every call to a library function, instead of just paging though the log file.<|eor|><|sor|>That's what breakpoints are for.<|eor|><|sor|>I've given this a try; I really have. But usually in these cases, I spend 40 iterations clicking 'continue' and hoping that stuff doesn't time-out, only to discover I put the breakpoint at the wrong spot.<|eor|><|eols|><|endoftext|>
5
lolphp
Takeoded
fgkt6r
<|sols|><|sot|>Array is higher than infinity<|eot|><|sol|>https://3v4l.org/iONLA<|eol|><|eols|><|endoftext|>
44
lolphp
tending
fk6a4jo
<|sols|><|sot|>Array is higher than infinity<|eot|><|sol|>https://3v4l.org/iONLA<|eol|><|sor|>https://www.php.net/manual/en/language.operators.comparison.php Comparison with Various Types Type of Operand 1| Type of Operand 2| Result ---|---|---- null or string| string| Convert NULL to "", numerical or lexical comparison bool or null| anything | Convert both sides to bool, FALSE < TRUE object| object | Built-in classes can define its own comparison, different classes are uncomparable, same class see Object Comparison string, resource or number| string, resource or number| Translate strings and resources to numbers, usual math array | array | Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value (see following example) object | anything | object is always greater **array** | **anything** | **array is always greater** Please, I welcome, how SHOULD this situation be handled? I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions without creating a double edged blade that will hurt at least one side. I guarantee whatever answer anybody suggests for how arrays should be compared to anything can easily have holes poked in it from some other angle, **there is no everybody-wins solution when you abstract away types and implicitly convert between types**.<|eor|><|sor|> >Please, I welcome, how SHOULD this situation be handled? > >I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions Correct, that's why well designed languages don't do this, or make their implicit conversions far more constrained. PHP is trying too hard to guess what the developer wants without having enough information to guess well. C++ for example has some implicit conversions. But user defined implicit conversions can't chain more than once, and there are no implicit conversions between totally unrelated types like arrays and scalars.<|eor|><|eols|><|endoftext|>
28
lolphp
Takeoded
fk6tuh0
<|sols|><|sot|>Array is higher than infinity<|eot|><|sol|>https://3v4l.org/iONLA<|eol|><|sor|>https://www.php.net/manual/en/language.operators.comparison.php Comparison with Various Types Type of Operand 1| Type of Operand 2| Result ---|---|---- null or string| string| Convert NULL to "", numerical or lexical comparison bool or null| anything | Convert both sides to bool, FALSE < TRUE object| object | Built-in classes can define its own comparison, different classes are uncomparable, same class see Object Comparison string, resource or number| string, resource or number| Translate strings and resources to numbers, usual math array | array | Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value (see following example) object | anything | object is always greater **array** | **anything** | **array is always greater** Please, I welcome, how SHOULD this situation be handled? I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions without creating a double edged blade that will hurt at least one side. I guarantee whatever answer anybody suggests for how arrays should be compared to anything can easily have holes poked in it from some other angle, **there is no everybody-wins solution when you abstract away types and implicitly convert between types**.<|eor|><|soopr|>> how SHOULD this situation be handled? [TypeError](https://www.php.net/manual/en/class.typeerror.php) or [InvalidArgumentException](https://www.php.net/manual/en/class.invalidargumentexception) ~~... or if it's Number[], perhaps treat the array as the value of it's highest member? that's what max() does if you give it *only* an array~~<|eoopr|><|eols|><|endoftext|>
17
lolphp
tending
fk6bdts
<|sols|><|sot|>Array is higher than infinity<|eot|><|sol|>https://3v4l.org/iONLA<|eol|><|sor|>https://www.php.net/manual/en/language.operators.comparison.php Comparison with Various Types Type of Operand 1| Type of Operand 2| Result ---|---|---- null or string| string| Convert NULL to "", numerical or lexical comparison bool or null| anything | Convert both sides to bool, FALSE < TRUE object| object | Built-in classes can define its own comparison, different classes are uncomparable, same class see Object Comparison string, resource or number| string, resource or number| Translate strings and resources to numbers, usual math array | array | Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value (see following example) object | anything | object is always greater **array** | **anything** | **array is always greater** Please, I welcome, how SHOULD this situation be handled? I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions without creating a double edged blade that will hurt at least one side. I guarantee whatever answer anybody suggests for how arrays should be compared to anything can easily have holes poked in it from some other angle, **there is no everybody-wins solution when you abstract away types and implicitly convert between types**.<|eor|><|sor|> >Please, I welcome, how SHOULD this situation be handled? > >I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions Correct, that's why well designed languages don't do this, or make their implicit conversions far more constrained. PHP is trying too hard to guess what the developer wants without having enough information to guess well. C++ for example has some implicit conversions. But user defined implicit conversions can't chain more than once, and there are no implicit conversions between totally unrelated types like arrays and scalars.<|eor|><|sor|>> PHP is trying too hard to guess what the developer wants I wouldn't say it's trying too hard, it simply has a place on the spectrum of convenience and fucked up edge cases to inconvenience and well defined. Some people might like exactly how much it is "trying", because, it's not like these cases are unpredictable. A good PHP programmer understands the limitations of implicit type conversions and knows how to write safe code that respects it and doesn't trigger (or worse, rely on) these wacky edge cases. So, for example, could that lead to more efficient work because they can simply reply on the implicit typing everywhere?<|eor|><|sor|>Take a valid PHP code snippet that does something nontrivial. Now count how many single character changes are also accepted by the interpreter but don't do what you intend (no helpful diagnostic error, just bad behavior). If that number is high, its just bad language design. You're arguing that it's a spectrum with trade offs. But you're assuming PHP is on the Pareto frontier (where you can't do better at ex without doing worse at Y). PHP probably isn't...<|eor|><|eols|><|endoftext|>
14
lolphp
CarnivorousSociety
fk5z3rh
<|sols|><|sot|>Array is higher than infinity<|eot|><|sol|>https://3v4l.org/iONLA<|eol|><|sor|>https://www.php.net/manual/en/language.operators.comparison.php Comparison with Various Types Type of Operand 1| Type of Operand 2| Result ---|---|---- null or string| string| Convert NULL to "", numerical or lexical comparison bool or null| anything | Convert both sides to bool, FALSE < TRUE object| object | Built-in classes can define its own comparison, different classes are uncomparable, same class see Object Comparison string, resource or number| string, resource or number| Translate strings and resources to numbers, usual math array | array | Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value (see following example) object | anything | object is always greater **array** | **anything** | **array is always greater** Please, I welcome, how SHOULD this situation be handled? I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions without creating a double edged blade that will hurt at least one side. I guarantee whatever answer anybody suggests for how arrays should be compared to anything can easily have holes poked in it from some other angle, **there is no everybody-wins solution when you abstract away types and implicitly convert between types**.<|eor|><|eols|><|endoftext|>
11
lolphp
slifin
fk5hddx
<|sols|><|sot|>Array is higher than infinity<|eot|><|sol|>https://3v4l.org/iONLA<|eol|><|sor|>This can be simplified to [https://3v4l.org/4abDY](https://3v4l.org/4abDY) I was looking at this the other day, if anyone can explain how PHP compares arrays I'd be very interested, i.e. what does PHP do internally with this kind of thing? `['a' => 1, 'b' => 1] > ['a' => 2]`<|eor|><|eols|><|endoftext|>
10
lolphp
ZorbaTHut
fk7hoqf
<|sols|><|sot|>Array is higher than infinity<|eot|><|sol|>https://3v4l.org/iONLA<|eol|><|sor|>https://www.php.net/manual/en/language.operators.comparison.php Comparison with Various Types Type of Operand 1| Type of Operand 2| Result ---|---|---- null or string| string| Convert NULL to "", numerical or lexical comparison bool or null| anything | Convert both sides to bool, FALSE < TRUE object| object | Built-in classes can define its own comparison, different classes are uncomparable, same class see Object Comparison string, resource or number| string, resource or number| Translate strings and resources to numbers, usual math array | array | Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value (see following example) object | anything | object is always greater **array** | **anything** | **array is always greater** Please, I welcome, how SHOULD this situation be handled? I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions without creating a double edged blade that will hurt at least one side. I guarantee whatever answer anybody suggests for how arrays should be compared to anything can easily have holes poked in it from some other angle, **there is no everybody-wins solution when you abstract away types and implicitly convert between types**.<|eor|><|soopr|>> how SHOULD this situation be handled? [TypeError](https://www.php.net/manual/en/class.typeerror.php) or [InvalidArgumentException](https://www.php.net/manual/en/class.invalidargumentexception) ~~... or if it's Number[], perhaps treat the array as the value of it's highest member? that's what max() does if you give it *only* an array~~<|eoopr|><|sor|>Then you don't have implicit conversions. Not to mention there is no function call in a simple comparison Then you just get errors when you try to implicitly convert, which is a feature of PHP 7 anyway, is it not?<|eor|><|sor|>Implicit conversions make *some* sense when you have an implicit conversion that makes sense. You're moving into nutcase territory when you just decide to do arbitrary things so that everything can convert to everything else. In this case, it doesn't make sense to compare two tables, and there's no sensible conversion for either table where it makes sense to compare to the other table. It should just spit out an error. If the language designer doesn't want to make it an exception or a terminating error, it should *at least* follow the pattern established by NaN and return false.<|eor|><|eols|><|endoftext|>
7
lolphp
tending
fk73hrv
<|sols|><|sot|>Array is higher than infinity<|eot|><|sol|>https://3v4l.org/iONLA<|eol|><|sor|>https://www.php.net/manual/en/language.operators.comparison.php Comparison with Various Types Type of Operand 1| Type of Operand 2| Result ---|---|---- null or string| string| Convert NULL to "", numerical or lexical comparison bool or null| anything | Convert both sides to bool, FALSE < TRUE object| object | Built-in classes can define its own comparison, different classes are uncomparable, same class see Object Comparison string, resource or number| string, resource or number| Translate strings and resources to numbers, usual math array | array | Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value (see following example) object | anything | object is always greater **array** | **anything** | **array is always greater** Please, I welcome, how SHOULD this situation be handled? I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions without creating a double edged blade that will hurt at least one side. I guarantee whatever answer anybody suggests for how arrays should be compared to anything can easily have holes poked in it from some other angle, **there is no everybody-wins solution when you abstract away types and implicitly convert between types**.<|eor|><|sor|> >Please, I welcome, how SHOULD this situation be handled? > >I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions Correct, that's why well designed languages don't do this, or make their implicit conversions far more constrained. PHP is trying too hard to guess what the developer wants without having enough information to guess well. C++ for example has some implicit conversions. But user defined implicit conversions can't chain more than once, and there are no implicit conversions between totally unrelated types like arrays and scalars.<|eor|><|sor|>> PHP is trying too hard to guess what the developer wants I wouldn't say it's trying too hard, it simply has a place on the spectrum of convenience and fucked up edge cases to inconvenience and well defined. Some people might like exactly how much it is "trying", because, it's not like these cases are unpredictable. A good PHP programmer understands the limitations of implicit type conversions and knows how to write safe code that respects it and doesn't trigger (or worse, rely on) these wacky edge cases. So, for example, could that lead to more efficient work because they can simply reply on the implicit typing everywhere?<|eor|><|sor|>Take a valid PHP code snippet that does something nontrivial. Now count how many single character changes are also accepted by the interpreter but don't do what you intend (no helpful diagnostic error, just bad behavior). If that number is high, its just bad language design. You're arguing that it's a spectrum with trade offs. But you're assuming PHP is on the Pareto frontier (where you can't do better at ex without doing worse at Y). PHP probably isn't...<|eor|><|sor|>> If that number is high, its just bad language design. I see what you're saying here. > but don't do what you **intend** But, that is still subjective. Whether a programmer can **intend** for a change to do the thing it will actually do is based on how well that programmer knows the language. So if you run that formula against a "theoretically perfect" programmer, every single change you make will do what they intend, because they know the language "perfectly". My point being that this is ultimately still subjective: > If that number is high, its just bad language design. Some people may like the freedom, and if they know the defined boundaries of the freedom then those cases where input doesn't result in intended output (in the realm of implicit conversions) are virtually eliminated.<|eor|><|sor|> >Some people may like the freedom, and if they know the defined boundaries of the freedom then those cases where input doesn't result in intended output (in the realm of implicit conversions) are virtually eliminated. You're assuming a world where people only make mistakes because they don't know things. Programmers have to keep lots and lots of things in their head. It's impossible to not be constantly making mistakes. Typos, forgetting the best language idiom to do a thing, not recognizing edge cases, forgetting about counter intuitive language behaviors (php!), not drinking their coffee, etc.<|eor|><|eols|><|endoftext|>
6
lolphp
Sarcastinator
fk7g335
<|sols|><|sot|>Array is higher than infinity<|eot|><|sol|>https://3v4l.org/iONLA<|eol|><|sor|>https://www.php.net/manual/en/language.operators.comparison.php Comparison with Various Types Type of Operand 1| Type of Operand 2| Result ---|---|---- null or string| string| Convert NULL to "", numerical or lexical comparison bool or null| anything | Convert both sides to bool, FALSE < TRUE object| object | Built-in classes can define its own comparison, different classes are uncomparable, same class see Object Comparison string, resource or number| string, resource or number| Translate strings and resources to numbers, usual math array | array | Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value (see following example) object | anything | object is always greater **array** | **anything** | **array is always greater** Please, I welcome, how SHOULD this situation be handled? I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions without creating a double edged blade that will hurt at least one side. I guarantee whatever answer anybody suggests for how arrays should be compared to anything can easily have holes poked in it from some other angle, **there is no everybody-wins solution when you abstract away types and implicitly convert between types**.<|eor|><|sor|> >Please, I welcome, how SHOULD this situation be handled? > >I posit that implicit conversions are the source of 99% of lolphp posts, there is no elegant way to solve implicit conversions Correct, that's why well designed languages don't do this, or make their implicit conversions far more constrained. PHP is trying too hard to guess what the developer wants without having enough information to guess well. C++ for example has some implicit conversions. But user defined implicit conversions can't chain more than once, and there are no implicit conversions between totally unrelated types like arrays and scalars.<|eor|><|sor|>> PHP is trying too hard to guess what the developer wants I wouldn't say it's trying too hard, it simply has a place on the spectrum of convenience and fucked up edge cases to inconvenience and well defined. Some people might like exactly how much it is "trying", because, it's not like these cases are unpredictable. A good PHP programmer understands the limitations of implicit type conversions and knows how to write safe code that respects it and doesn't trigger (or worse, rely on) these wacky edge cases. So, for example, could that lead to more efficient work because they can simply reply on the implicit typing everywhere?<|eor|><|sor|>Take a valid PHP code snippet that does something nontrivial. Now count how many single character changes are also accepted by the interpreter but don't do what you intend (no helpful diagnostic error, just bad behavior). If that number is high, its just bad language design. You're arguing that it's a spectrum with trade offs. But you're assuming PHP is on the Pareto frontier (where you can't do better at ex without doing worse at Y). PHP probably isn't...<|eor|><|sor|>> If that number is high, its just bad language design. I see what you're saying here. > but don't do what you **intend** But, that is still subjective. Whether a programmer can **intend** for a change to do the thing it will actually do is based on how well that programmer knows the language. So if you run that formula against a "theoretically perfect" programmer, every single change you make will do what they intend, because they know the language "perfectly". My point being that this is ultimately still subjective: > If that number is high, its just bad language design. Some people may like the freedom, and if they know the defined boundaries of the freedom then those cases where input doesn't result in intended output (in the realm of implicit conversions) are virtually eliminated.<|eor|><|sor|>Let's be realistic. If PHP was designed today this behavior would not have been included. It's an artifact of a bygone era largely in place because of Perl.<|eor|><|eols|><|endoftext|>
6