subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
IrrelevantXKCD-Bot
d9rq39u
<|sols|><|sot|>DateTime::ISO8601 is not ISO-8601 compatible<|eot|><|sol|>http://php.net/manual/en/class.datetime.php#datetime.constants.types<|eol|><|sor|>Some people get frustrated with e.g. Java due to the burden backward compatibility places on the speed and direction of language and core library development ... but this makes it sound like the PHP designers are intentionally keeping straight up *bugs* around for the sake of backward compatibility. Interesting decision on their part.<|eor|><|sor|>[deleted]<|eor|><|sor|>###[Irrelevant xkcd](http://xkcd.com/367/) ********** I'm a bot bleep, bloop<|eor|><|eols|><|endoftext|>
9
lolphp
emilvikstrom
d9sldqh
<|sols|><|sot|>DateTime::ISO8601 is not ISO-8601 compatible<|eot|><|sol|>http://php.net/manual/en/class.datetime.php#datetime.constants.types<|eol|><|sor|>[ISO8601 has changed several times over the years.](https://en.wikipedia.org/wiki/ISO_8601#History) * ISO 8601:1988 * ISO 8601:2000 * ISO 8601:2004 <|eor|><|sor|>Which one of them is PHP compatible with?<|eor|><|eols|><|endoftext|>
7
lolphp
qwerty6868
daao01w
<|sols|><|sot|>DateTime::ISO8601 is not ISO-8601 compatible<|eot|><|sol|>http://php.net/manual/en/class.datetime.php#datetime.constants.types<|eol|><|sor|>[ISO8601 has changed several times over the years.](https://en.wikipedia.org/wiki/ISO_8601#History) * ISO 8601:1988 * ISO 8601:2000 * ISO 8601:2004 <|eor|><|sor|>Which one of them is PHP compatible with?<|eor|><|sor|>None<|eor|><|eols|><|endoftext|>
7
lolphp
lol_no_generics
da4qih1
<|sols|><|sot|>DateTime::ISO8601 is not ISO-8601 compatible<|eot|><|sol|>http://php.net/manual/en/class.datetime.php#datetime.constants.types<|eol|><|sor|>> Note: This format is not compatible with ISO-8601, but is left this way for backward compatibility reasons. TIL "backward compatibility" is the opposite of "compatibility"<|eor|><|eols|><|endoftext|>
6
lolphp
kEQuA7VxEb
3hm7hh
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|eoss|><|endoftext|>
102
lolphp
Various_Pickles
cu8yfu1
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|sor|>Probably some "false means null means undefined means no type so far" logic so that using empty (in PHP terms) variables in an array-like way makes them arrays in order to avoid the unpleasant burden of correctly instantiating the array. Using the boolean value true as an array is clearly wrong, even for PHP.<|eor|><|sor|>If you use the string "nipplechocolate" instead, the associated var_dump() function call will be coerced into a bitmap of a small turtle prior to invocation. A silent warning will be printed to another web server (you'll have to call nipplechocolate_error() over there to catch it) and the entire code block will return 0, false, or "ftrue" depending on absolutely nothing.<|eor|><|eoss|><|endoftext|>
35
lolphp
Schmittfried
cu8upud
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|sor|>Probably some "false means null means undefined means no type so far" logic so that using empty (in PHP terms) variables in an array-like way makes them arrays in order to avoid the unpleasant burden of correctly instantiating the array. Using the boolean value true as an array is clearly wrong, even for PHP.<|eor|><|eoss|><|endoftext|>
30
lolphp
Regimardyl
cu8o1qu
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|eoss|><|endoftext|>
24
lolphp
maweki
cu9f51g
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|> $v = ""; $v[4] = "foo"; This does what we've talked about. But did you guys know what happens with a non-empty-string? $v = "2"; $v[4] = "foo"; var_dump($v); string(5) "2 f" The string is filled up with spaces. But not the empty string.<|eor|><|eoss|><|endoftext|>
21
lolphp
Schmittfried
cu92w1r
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|sor|>Probably some "false means null means undefined means no type so far" logic so that using empty (in PHP terms) variables in an array-like way makes them arrays in order to avoid the unpleasant burden of correctly instantiating the array. Using the boolean value true as an array is clearly wrong, even for PHP.<|eor|><|soopr|>Unfortunately, it's not even that simple. $thevar=""; $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=0; $thevar["that"]=5; var_dump($thevar); // stderr - PHP Warning: Cannot use a scalar value as an array // int(0)<|eoopr|><|sor|>The first one still fits my assumption. "" also coerces to false/null. The second one is a surprise though. Seriously, how the fuck did they implement that algorithm and how did they come up with it in the first place? Is anyone keen enough to look into the C code?<|eor|><|eoss|><|endoftext|>
19
lolphp
Sjoerder
cu9ayyo
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|sor|>Probably some "false means null means undefined means no type so far" logic so that using empty (in PHP terms) variables in an array-like way makes them arrays in order to avoid the unpleasant burden of correctly instantiating the array. Using the boolean value true as an array is clearly wrong, even for PHP.<|eor|><|soopr|>Unfortunately, it's not even that simple. $thevar=""; $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=0; $thevar["that"]=5; var_dump($thevar); // stderr - PHP Warning: Cannot use a scalar value as an array // int(0)<|eoopr|><|sor|>The first one still fits my assumption. "" also coerces to false/null. The second one is a surprise though. Seriously, how the fuck did they implement that algorithm and how did they come up with it in the first place? Is anyone keen enough to look into the C code?<|eor|><|sor|>[Here it is](https://github.com/php/php-src/blob/php-5.6.12/Zend/zend_execute.c#L1276). It basically says if it is null or an empty string or boolean false, then convert it to an array. Unfortunately it doesn't say why.<|eor|><|eoss|><|endoftext|>
18
lolphp
kEQuA7VxEb
cu8x0jl
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|sor|>Probably some "false means null means undefined means no type so far" logic so that using empty (in PHP terms) variables in an array-like way makes them arrays in order to avoid the unpleasant burden of correctly instantiating the array. Using the boolean value true as an array is clearly wrong, even for PHP.<|eor|><|soopr|>Unfortunately, it's not even that simple. $thevar=""; $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=0; $thevar["that"]=5; var_dump($thevar); // stderr - PHP Warning: Cannot use a scalar value as an array // int(0)<|eoopr|><|eoss|><|endoftext|>
17
lolphp
salty-sardines
cu9ot9r
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|sor|>Probably some "false means null means undefined means no type so far" logic so that using empty (in PHP terms) variables in an array-like way makes them arrays in order to avoid the unpleasant burden of correctly instantiating the array. Using the boolean value true as an array is clearly wrong, even for PHP.<|eor|><|soopr|>Unfortunately, it's not even that simple. $thevar=""; $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=0; $thevar["that"]=5; var_dump($thevar); // stderr - PHP Warning: Cannot use a scalar value as an array // int(0)<|eoopr|><|sor|>The first one still fits my assumption. "" also coerces to false/null. The second one is a surprise though. Seriously, how the fuck did they implement that algorithm and how did they come up with it in the first place? Is anyone keen enough to look into the C code?<|eor|><|sor|>[Here it is](https://github.com/php/php-src/blob/php-5.6.12/Zend/zend_execute.c#L1276). It basically says if it is null or an empty string or boolean false, then convert it to an array. Unfortunately it doesn't say why.<|eor|><|sor|>Oh... oh, wow. I thought this was just an artifact of PHP's value encodinglike, false/null/empty string were all encoded as the same value, which passed an "emptiness" check in the array write. Nope, it's an intentional design decision with an explicit implementation for each separate type. Astonishing.<|eor|><|eoss|><|endoftext|>
15
lolphp
maweki
cu9f8l2
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|> $v = ""; $v[4] = "foo"; This does what we've talked about. But did you guys know what happens with a non-empty-string? $v = "2"; $v[4] = "foo"; var_dump($v); string(5) "2 f" The string is filled up with spaces. But not the empty string.<|eor|><|sor|>So $v[5] = "f"; will set the fifth letter of the string $v to f for any string **except** if $v is the empty string.<|eor|><|eoss|><|endoftext|>
10
lolphp
deuxpi
cuoha6q
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|sor|>Probably some "false means null means undefined means no type so far" logic so that using empty (in PHP terms) variables in an array-like way makes them arrays in order to avoid the unpleasant burden of correctly instantiating the array. Using the boolean value true as an array is clearly wrong, even for PHP.<|eor|><|soopr|>Unfortunately, it's not even that simple. $thevar=""; $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=0; $thevar["that"]=5; var_dump($thevar); // stderr - PHP Warning: Cannot use a scalar value as an array // int(0)<|eoopr|><|sor|>The first one still fits my assumption. "" also coerces to false/null. The second one is a surprise though. Seriously, how the fuck did they implement that algorithm and how did they come up with it in the first place? Is anyone keen enough to look into the C code?<|eor|><|sor|>[Here it is](https://github.com/php/php-src/blob/php-5.6.12/Zend/zend_execute.c#L1276). It basically says if it is null or an empty string or boolean false, then convert it to an array. Unfortunately it doesn't say why.<|eor|><|sor|>Relevant commits: * [0b8ea2883207d3a8359ef135879ebe81b1374afb](https://github.com/php/php-src/commit/0b8ea2883207d3a8359ef135879ebe81b1374afb) "incompatibility with PHP 3" * [d3cad4f289bf7612dc4e431149051420fc05555c](https://github.com/php/php-src/commit/d3cad4f289bf7612dc4e431149051420fc05555c) "Functionality" So hum... half deliberate behavior and half backward compatibility with another era?<|eor|><|eoss|><|endoftext|>
8
lolphp
BufferUnderpants
cuo1kdj
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|> $v = ""; $v[4] = "foo"; This does what we've talked about. But did you guys know what happens with a non-empty-string? $v = "2"; $v[4] = "foo"; var_dump($v); string(5) "2 f" The string is filled up with spaces. But not the empty string.<|eor|><|sor|>Is this the same principle as the wello php one?<|eor|><|sor|>What is "the wello php one"?<|eor|><|sor|> <?php $a = array(); $a['foo'] = "Hello"; $a['foo']['bar'] = "World"; var_dump($a); Guess what's the output of `var_dump`.<|eor|><|eoss|><|endoftext|>
7
lolphp
webdeverper
cubb3ug
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|sor|>Probably some "false means null means undefined means no type so far" logic so that using empty (in PHP terms) variables in an array-like way makes them arrays in order to avoid the unpleasant burden of correctly instantiating the array. Using the boolean value true as an array is clearly wrong, even for PHP.<|eor|><|sor|>If you use the string "nipplechocolate" instead, the associated var_dump() function call will be coerced into a bitmap of a small turtle prior to invocation. A silent warning will be printed to another web server (you'll have to call nipplechocolate_error() over there to catch it) and the entire code block will return 0, false, or "ftrue" depending on absolutely nothing.<|eor|><|sor|>I did that one time. It was turtles all the way down, recursively. <|eor|><|eoss|><|endoftext|>
6
lolphp
Regimardyl
cu8vwwj
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>What about this? $thevar = 5; $thevar["five"] = 5;<|eor|><|sor|>Same effect as `true`: https://3v4l.org/QBftC (also doesn't work with 0 as a scalar)<|eor|><|eoss|><|endoftext|>
5
lolphp
coredumperror
cuefye5
<|soss|><|sot|>Conjure Arrays from nothing<|eot|><|sost|> <?php //$thevar starts undefined $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=null; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // NULL // array(1) { // ["that"]=> // int(5) // } $thevar=false; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(false) // array(1) { // ["that"]=> // int(5) // } // all code above outputs with no warnings $thevar=true; var_dump($thevar); $thevar["that"]=5; var_dump($thevar); // outputs // bool(true) // stderr - PHP Warning: Cannot use a scalar value as an array // bool(true) With syntax highlighting http://pastebin.com/0pYk3chD<|eost|><|sor|>https://3v4l.org/TuQvK this is real o.O Really interested in what causes it though <|eor|><|sor|>Probably some "false means null means undefined means no type so far" logic so that using empty (in PHP terms) variables in an array-like way makes them arrays in order to avoid the unpleasant burden of correctly instantiating the array. Using the boolean value true as an array is clearly wrong, even for PHP.<|eor|><|soopr|>Unfortunately, it's not even that simple. $thevar=""; $thevar["that"]=5; var_dump($thevar); // outputs // array(1) { // ["that"]=> // int(5) // } $thevar=0; $thevar["that"]=5; var_dump($thevar); // stderr - PHP Warning: Cannot use a scalar value as an array // int(0)<|eoopr|><|sor|>The first one still fits my assumption. "" also coerces to false/null. The second one is a surprise though. Seriously, how the fuck did they implement that algorithm and how did they come up with it in the first place? Is anyone keen enough to look into the C code?<|eor|><|sor|>[Here it is](https://github.com/php/php-src/blob/php-5.6.12/Zend/zend_execute.c#L1276). It basically says if it is null or an empty string or boolean false, then convert it to an array. Unfortunately it doesn't say why.<|eor|><|sor|>Oh... oh, wow. I thought this was just an artifact of PHP's value encodinglike, false/null/empty string were all encoded as the same value, which passed an "emptiness" check in the array write. Nope, it's an intentional design decision with an explicit implementation for each separate type. Astonishing.<|eor|><|sor|>> Astonishing. I wish that were actually true... but this is PHP. I'm not even surprised.<|eor|><|eoss|><|endoftext|>
5
lolphp
gibranois
41fqib
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|eols|><|endoftext|>
104
lolphp
tdammers
cz1zerv
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|eols|><|endoftext|>
69
lolphp
phpguy2
cz27uxm
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>>Consider that there is no loss of information. Oh. So, according to you, the original type of the key is no information at all. Right?<|eor|><|eols|><|endoftext|>
30
lolphp
tdammers
cz2h1j2
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>There is, if it happens implicitly. Especially considering how a PHP array can in fact be one of (at least) two types with distinct semantics and no convenient way of checking which one it is, and it depends on the keys you use whoch one you get. Also, there *is* loss of information, namely the type and exact string representantion of our key-that-happens-to-parse-as-int. This means that our usual intuitions wrt equality and identity don't hold, in particular, 'equal in an array indexing situation' and 'equal in direct comparison' no longer imply each other, in neither direction.<|eor|><|eols|><|endoftext|>
24
lolphp
postmodest
cz23399
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>The fucky bit is that you can end up with dumb crap like $x = ["0"=>'zero',"3"=>"one"]; Why PHP doesn't have separate hashes and arrays is one of those "why didn't you just fucking use Perl" questions I'd like to get printed on a cricket bat and hit Rasmus over the head with.<|eor|><|eols|><|endoftext|>
22
lolphp
the_alias_of_andrea
cz2cc12
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>>Consider that there is no loss of information. Oh. So, according to you, the original type of the key is no information at all. Right?<|eor|><|sor|>No, the type conveys information, but it's not especially important. Consider that PHP is a weakly-typed language where it doesn't matter. Keeping the type information here creates its own set of problems.<|eor|><|sor|>and what problems are those?<|eor|><|sor|>It violates weak typing, for one. Weak typing is not necessarily a good thing (certainly PHP's rules are weird), but having arrays be an exception to it would be unhelpful and inconsistent. Remember that PHP generally considers "1", 1 and 1.0 to be equivalent. If arrays treated them as distinct, this would make for quite brittle code and be unintuitive given the rest of the language. It's also inconvenient: you currently don't have to cast indices to integers yourself. If PHP preserved types in the other way (requiring all keys to be strings), this would be unperformant.<|eor|><|eols|><|endoftext|>
22
lolphp
redwall_hp
cz2e69x
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>The fucky bit is that you can end up with dumb crap like $x = ["0"=>'zero',"3"=>"one"]; Why PHP doesn't have separate hashes and arrays is one of those "why didn't you just fucking use Perl" questions I'd like to get printed on a cricket bat and hit Rasmus over the head with.<|eor|><|sor|>Learning PHP as my first "real" language (aside from BASIC and JavaScript in the days when the phrase "DHTML" was a thing) was a major mistake in the greater scope of programming. Unlearning the mess of bad habits it teaches wasn't hard. Its...unusual array system and disregard for types makes it a bit harder to grasp typical data structures and languages that take types more seriously (either dynamic or static). You don't need to know what a linked list or hash table are in PHP, because its arrays try to do everything. And I don't think I truly grasped the practical purpose of data structure classes over the ideological concept until I started writing Java. Because when you can't fake it with messy PHP arrays, you have to actually make use of encapsulation and write proper classes to represent data. Only learning one language is severely limiting to a programmer.<|eor|><|eols|><|endoftext|>
17
lolphp
Fs0i
cz2fysd
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Actually, Perl behaves the same as PHP in that regard. [Because Perl is a good example in behaving obvious](https://media.ccc.de/v/31c3_-_6243_-_en_-_saal_1_-_201412292200_-_the_perl_jam_exploiting_a_20_year-old_vulnerability_-_netanel_rubin), and [makes it hard to write buggy code](https://media.ccc.de/v/32c3-7130-the_perl_jam_2) (I can only recomment the 1st of the two talks, the 2nd one isn't *as good* imo)<|eor|><|eols|><|endoftext|>
13
lolphp
tdammers
cz3p0iy
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>There is, if it happens implicitly. Especially considering how a PHP array can in fact be one of (at least) two types with distinct semantics and no convenient way of checking which one it is, and it depends on the keys you use whoch one you get. Also, there *is* loss of information, namely the type and exact string representantion of our key-that-happens-to-parse-as-int. This means that our usual intuitions wrt equality and identity don't hold, in particular, 'equal in an array indexing situation' and 'equal in direct comparison' no longer imply each other, in neither direction.<|eor|><|sor|>> Especially considering how a PHP array can in fact be one of (at least) two types with distinct semantics and no convenient way of checking which one it is, and it depends on the keys you use whoch one you get. Uh, what? It's a single data type with multiple uses. There's not two kinds of arrays. > Also, there is loss of information, namely the type and exact string representantion of our key-that-happens-to-parse-as-int. The exact string representation isn't lost. There's a one-to-one string-to-integer relationship. If it's converted to an integer, then you can convert it back to a string and get *exactly* the same value.<|eor|><|sor|>> Uh, what? It's a single data type with multiple uses. There's not two kinds of arrays. No, there's two, and they behave differently. One kind is the one you see most often: an ordered key/value container of (mostly) arbitrary keys. This is what you get when you assign to non-integer keys, and also when you leave gaps. The other kind is closer to an actual array, with 0-based sequential integer keys. This is what you get when you start with an empty array and just append items to the end (e.g. using `$a[] = $something`), and also the output of most of the functions that can be expected to return a flat list (e.g. `array_values`, etc.). Their semantics are sufficiently different, and there are many subtle gotchas because of it. > The exact string representation isn't lost. There's a one-to-one string-to-integer relationship. If it's converted to an integer, then you can convert it back to a string and get exactly the same value. Yes it is lost, and no, there's not a one-to-one relationship. Not if the specification is "numeric string literals are always converted to integer, and the conversion is accurate". It turns out, however, that neither holds: not every numeric string is auto-converted to integer in this scenario, even when it normally would be (e.g., passing `'0xff'`, which in most other cases will be converted to 255 when used numerically, will produce the key `'0xff`, not the key `255`); the string `"18446744073709551615"` remains unconverted also, even though the integer literal `18446744073709551615` yields the string key `0` (due to an unhandled integer overflow, I presume). And, either way, you still lose the original type information, i.e., you cannot tell later whether the key was passed in as an integer or a string, even though both types are supported as keys. Actually, that is a pretty stupid idea even, because now we can only store *some* strings, which in turn means that if we want an array where all the keys are strings, then some things (specifically, keys that are numeric strings) cannot be stored in it. So it turns out this one specific problem was "fixed" (in the form of a special-case string-to-integer conversion that diverges from the normal behavior), but the other issues weren't, and the fix comes at the cost of now having two different ways in which a string can become an integer. Par for the course, I guess.<|eor|><|eols|><|endoftext|>
10
lolphp
gibranois
cz55d6j
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>if you have externally supplied data that you want to keep as array indexes, you're potentially screwed. Let's say the externally supplied data is "ABC" and "123" and you put that into an array as keys $foo = ["ABC" => 8533, "123" => 9752]; and then later you want to pull the data out again and you're a good citizen and use the === operator: foreach ($foo as $id => $value){ if ($id === $user_supplied_value_123){ } } now you're screwed. <|eor|><|sor|>Yeah, that's the case where it falls apart, unfortunately. Otherwise the conversion is harmless.<|eor|><|soopr|>A: Should I wear seat belts? Php core dev: No. it is safe to drive with out seat belts. A: What if I have an head on collision and smash my head on the wheel? Php core dev: Yeah, that's the case where it falls apart, unfortunately. Otherwise the driving without seat belts is harmless. But hey, you know most of the people who drive without seat belts end up just fine. So you should be ok. A: !!?? <|eoopr|><|eols|><|endoftext|>
9
lolphp
the_alias_of_andrea
cz24ew7
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>The fucky bit is that you can end up with dumb crap like $x = ["0"=>'zero',"3"=>"one"]; Why PHP doesn't have separate hashes and arrays is one of those "why didn't you just fucking use Perl" questions I'd like to get printed on a cricket bat and hit Rasmus over the head with.<|eor|><|sor|>> The fucky bit is that you can end up with dumb crap like > > $x = ["0"=>'zero',"3"=>"one"]; What, exactly, is that an example of?<|eor|><|eols|><|endoftext|>
8
lolphp
pilif
cz2po7m
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>if you have externally supplied data that you want to keep as array indexes, you're potentially screwed. Let's say the externally supplied data is "ABC" and "123" and you put that into an array as keys $foo = ["ABC" => 8533, "123" => 9752]; and then later you want to pull the data out again and you're a good citizen and use the === operator: foreach ($foo as $id => $value){ if ($id === $user_supplied_value_123){ } } now you're screwed. <|eor|><|eols|><|endoftext|>
8
lolphp
squiggleslash
cz3vis3
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>There is, if it happens implicitly. Especially considering how a PHP array can in fact be one of (at least) two types with distinct semantics and no convenient way of checking which one it is, and it depends on the keys you use whoch one you get. Also, there *is* loss of information, namely the type and exact string representantion of our key-that-happens-to-parse-as-int. This means that our usual intuitions wrt equality and identity don't hold, in particular, 'equal in an array indexing situation' and 'equal in direct comparison' no longer imply each other, in neither direction.<|eor|><|sor|>A PHP array is not one of two types of distinct semantics... unfortunately. It's one bizarre frankentype that tries to be both an array and a hash table, and does it at the same time, using the same semantics. That is an LOL, and it's the type of LOL - like false, "", "0" and 0 all being equivalent to one another - that ends up having a chain reaction that causes unexpected behavior throughout the rest of the system. Curiously, Javascript has the same issue. I wonder which came first. It's still terrible though. The string encoded numbers can't be keys issue is a legitimate restriction, but it's a restriction we shouldn't need to have because array() and lookuptable() should have been different types to begin with. Mind you, objects, another frankentype, work correctly here: <?php $index = "5"; $obj = (object)null; $obj->$index = 100; foreach($obj as $key => $value) { echo "$key => $value\n"; } outputs: 5 => 100 ...so there's always that available if you need to use numeric keys. <|eor|><|eols|><|endoftext|>
8
lolphp
the_alias_of_andrea
cz28d6h
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>>Consider that there is no loss of information. Oh. So, according to you, the original type of the key is no information at all. Right?<|eor|><|sor|>No, the type conveys information, but it's not especially important. Consider that PHP is a weakly-typed language where it doesn't matter. Keeping the type information here creates its own set of problems.<|eor|><|eols|><|endoftext|>
8
lolphp
phpguy2
cz2e3aa
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>>Consider that there is no loss of information. Oh. So, according to you, the original type of the key is no information at all. Right?<|eor|><|sor|>No, the type conveys information, but it's not especially important. Consider that PHP is a weakly-typed language where it doesn't matter. Keeping the type information here creates its own set of problems.<|eor|><|sor|>and what problems are those?<|eor|><|sor|>It violates weak typing, for one. Weak typing is not necessarily a good thing (certainly PHP's rules are weird), but having arrays be an exception to it would be unhelpful and inconsistent. Remember that PHP generally considers "1", 1 and 1.0 to be equivalent. If arrays treated them as distinct, this would make for quite brittle code and be unintuitive given the rest of the language. It's also inconvenient: you currently don't have to cast indices to integers yourself. If PHP preserved types in the other way (requiring all keys to be strings), this would be unperformant.<|eor|><|sor|>>It violates weak typing, for one. It does not have to. Why not keep the type and keep them as strings themselves and do the weak typing thing on comparison operations only? Also talk [about being consistant](https://3v4l.org/uBDle) <|eor|><|eols|><|endoftext|>
8
lolphp
pilif
cz34a55
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>if you have externally supplied data that you want to keep as array indexes, you're potentially screwed. Let's say the externally supplied data is "ABC" and "123" and you put that into an array as keys $foo = ["ABC" => 8533, "123" => 9752]; and then later you want to pull the data out again and you're a good citizen and use the === operator: foreach ($foo as $id => $value){ if ($id === $user_supplied_value_123){ } } now you're screwed. <|eor|><|sor|>Yeah, that's the case where it falls apart, unfortunately. Otherwise the conversion is harmless.<|eor|><|sor|>and this is an incredible pitfall and the reason why I believe PHP to be so dangerous. This is a case where it's actively fighting good practice (= using the === operator). Worse, it does it in a way where it's OK 99.9% of the time. It also means that you as a user of PHP need to keep this in mind at all times and it means that you have to add further unit tests that would otherwise not be needed (provided you think of the edge-cases - otherwise your seemingly perfect code will suddenly start failing in mysterious ways - certainly without error message or anything) <|eor|><|eols|><|endoftext|>
7
lolphp
milordi
cz35tud
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>*"It's not a bug, because it's documented behaviour!"* - classic PHP.<|eor|><|eols|><|endoftext|>
6
lolphp
ThisIsADogHello
cz2mmfl
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>The fucky bit is that you can end up with dumb crap like $x = ["0"=>'zero',"3"=>"one"]; Why PHP doesn't have separate hashes and arrays is one of those "why didn't you just fucking use Perl" questions I'd like to get printed on a cricket bat and hit Rasmus over the head with.<|eor|><|sor|>The part that gets me is that PHP mostly came about because "Perl is slow, but C is fast!"... so, he basically rewrote his own version of Perl that was significantly slower.<|eor|><|eols|><|endoftext|>
6
lolphp
hey_aaapple
cz2k611
<|sols|><|sot|>"It is so simple in Php, let me show you". "Mm. No it is broken". "Oh. It is just a contrived use case!"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1qnca<|eol|><|sor|>> Not being able to use numeric strings as associative keys is intentional and documented. This part made me die on the inside. Not just a little.<|eor|><|sor|>Why? Is there something inherently wrong with converting numeric string keys to integers? Consider that there is no loss of information.<|eor|><|sor|>Yes, since the two things are not conceptually identical: for example, some numerical strings like telephone numbers and some kinds of ID codes should NOT be treated like numbers.<|eor|><|eols|><|endoftext|>
6
lolphp
repie
3we125
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|eols|><|endoftext|>
102
lolphp
TheBuzzSaw
cxvkn4t
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>https://gist.github.com/maxrice/2776900#gistcomment-1200768 > Here is the list without Delaware TROLOLOLOLOL Too good.<|eor|><|eols|><|endoftext|>
52
lolphp
knaveofspades
cxvo4po
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>https://gist.github.com/maxrice/2776900#gistcomment-1200768 > Here is the list without Delaware TROLOLOLOLOL Too good.<|eor|><|soopr|>I'm not American and I missed this joke, can you explain please? :P<|eoopr|><|sor|>I don't think it has anything to do with Delaware other than the fact that the removal of a single item is one of the most superficial changes you can make to the array.<|eor|><|eols|><|endoftext|>
30
lolphp
knaveofspades
cxvr8jf
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>https://gist.github.com/maxrice/2776900#gistcomment-1200768 > Here is the list without Delaware TROLOLOLOLOL Too good.<|eor|><|soopr|>I'm not American and I missed this joke, can you explain please? :P<|eoopr|><|sor|>I don't think it has anything to do with Delaware other than the fact that the removal of a single item is one of the most superficial changes you can make to the array.<|eor|><|sor|>The Delaware thing is about Delaware being so small and unimportant that it cannot possibly qualify as a state. That's what this joke is about.<|eor|><|sor|>Ahh, with Rhode Island being so small and unimportant that it was looked over for Delaware as small and unimportant.<|eor|><|eols|><|endoftext|>
21
lolphp
postmodest
cxw8w5c
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>This is more "For the lols" than "lol, PHP". I can totally see a reason for things like $states = [ 'AL'=>'Alabama', 'AK'=>'Alaska', <...>]; And even $states = ['A' => ['AL'=>'Alabama', 'AK'=>'Alaska', <...>], <...>] And then obviously people are taking the piss with "without Delaware", but this isn't the usual PHP lollery where PHP does stupid shit or allows you to machine-gun your own foot because it makes some dumb thing faster. 2/10 keks.<|eor|><|eols|><|endoftext|>
19
lolphp
minimim
cxvnb7b
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>I don't get it.<|eor|><|eols|><|endoftext|>
14
lolphp
Wouter10123
cxvxhcn
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>This is gold<|eor|><|sor|>No, [this is gold](http://blog.wallstreetsurvivor.com/wp-content/uploads/gold.jpg).<|eor|><|sor|>No, that's a picture of gold. <|eor|><|eols|><|endoftext|>
14
lolphp
chimyx
cxvjqw0
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>This is gold<|eor|><|eols|><|endoftext|>
12
lolphp
tdammers
cxvqhup
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>https://gist.github.com/maxrice/2776900#gistcomment-1200768 > Here is the list without Delaware TROLOLOLOLOL Too good.<|eor|><|soopr|>I'm not American and I missed this joke, can you explain please? :P<|eoopr|><|sor|>I don't think it has anything to do with Delaware other than the fact that the removal of a single item is one of the most superficial changes you can make to the array.<|eor|><|sor|>The Delaware thing is about Delaware being so small and unimportant that it cannot possibly qualify as a state. That's what this joke is about.<|eor|><|eols|><|endoftext|>
12
lolphp
repie
cxvl9e3
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>https://gist.github.com/maxrice/2776900#gistcomment-1200768 > Here is the list without Delaware TROLOLOLOLOL Too good.<|eor|><|soopr|>I'm not American and I missed this joke, can you explain please? :P<|eoopr|><|eols|><|endoftext|>
10
lolphp
Drainedsoul
cxvwnpz
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>https://gist.github.com/maxrice/2776900#gistcomment-1200768 > Here is the list without Delaware TROLOLOLOLOL Too good.<|eor|><|soopr|>I'm not American and I missed this joke, can you explain please? :P<|eoopr|><|sor|>I don't think it has anything to do with Delaware other than the fact that the removal of a single item is one of the most superficial changes you can make to the array.<|eor|><|sor|>The Delaware thing is about Delaware being so small and unimportant that it cannot possibly qualify as a state. That's what this joke is about.<|eor|><|sor|>Ahh, with Rhode Island being so small and unimportant that it was looked over for Delaware as small and unimportant.<|eor|><|sor|>Imagine how much smaller it'd be were it just Rhode Island and not also Providence Plantations! <|eor|><|eols|><|endoftext|>
9
lolphp
Benutzername
cxwdrfu
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>>I had to retype them Capitalized and remove the territories. If only there was a tool that could do such a transformation for you.<|eor|><|eols|><|endoftext|>
8
lolphp
disclosure5
cxx5ety
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>I'm bookmarking this. Every time I ask an American where they are from, they'll say something like "I'm from PA" and then assume that of course, everyone knows that the hell that means. At least that beats "the Bay area", which we all know refers to Nelson Bay.<|eor|><|eols|><|endoftext|>
6
lolphp
suspiciously_calm
cxwc8rs
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>This is gold<|eor|><|sor|>No, [this is gold](http://blog.wallstreetsurvivor.com/wp-content/uploads/gold.jpg).<|eor|><|sor|>No, that's a picture of gold. <|eor|><|sor|>This is not a pipe.<|eor|><|eols|><|endoftext|>
6
lolphp
maweki
cxvlgis
<|sols|><|sot|>One does not simply put US State Names & Abbreviations in a PHP Array<|eot|><|sol|>https://gist.github.com/maxrice/2776900<|eol|><|sor|>https://gist.github.com/maxrice/2776900#gistcomment-1200768 > Here is the list without Delaware TROLOLOLOLOL Too good.<|eor|><|sor|>Well, if it is his use case...<|eor|><|eols|><|endoftext|>
5
lolphp
blueskin
1dfn0u
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|eols|><|endoftext|>
106
lolphp
n42
c9q3xez
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|> "php" == true => true 1 == true => true "php" == 1 => false what "php" == 0 => true *what*<|eor|><|eols|><|endoftext|>
27
lolphp
mybadluck22
c9q5dqb
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>If there are any loosely typed languages that don't have this problem, I'd love to hear about them. Do, for example, ruby or javascript fare much better?<|eor|><|sor|>generated this for javascript image: http://i.imgur.com/zdD2zsh.png source: http://codepen.io/anon/pen/Lyhek <|eor|><|sor|>Now with dazzling color: http://i.imgur.com/H2AHwtE.png source: http://codepen.io/anon/pen/jfIAw<|eor|><|eols|><|endoftext|>
16
lolphp
gearvOsh
c9q6trf
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|> "php" == true => true 1 == true => true "php" == 1 => false what "php" == 0 => true *what*<|eor|><|sor|>php is being type cast to an integer which results in 0, that's why it doesn't match a 1.<|eor|><|eols|><|endoftext|>
14
lolphp
gearvOsh
c9pzqqh
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>The chart makes it look confusing, but it's quite easy (for the most part). 0, '0', false, null, "", array() -> false everything else -> true The real gotchas are usually stringed integers and empty arrays. Personally, I'm never comparing an empty array to anything else besides an expression. if ($array) { }<|eor|><|eols|><|endoftext|>
13
lolphp
bgeron
c9q75hb
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>true == "php" == 0 == false<|eor|><|eols|><|endoftext|>
11
lolphp
n42
c9q4am8
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>If there are any loosely typed languages that don't have this problem, I'd love to hear about them. Do, for example, ruby or javascript fare much better?<|eor|><|sor|>generated this for javascript image: http://i.imgur.com/zdD2zsh.png source: http://codepen.io/anon/pen/Lyhek <|eor|><|eols|><|endoftext|>
11
lolphp
bjmiller
c9q0zv6
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>If there are any loosely typed languages that don't have this problem, I'd love to hear about them. Do, for example, ruby or javascript fare much better?<|eor|><|sor|>In ruby, the entire chart is "false" except for the diagonal representing identity comparisons, which are all "true".<|eor|><|eols|><|endoftext|>
11
lolphp
tef
c9q7hyt
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>this is a screenshot of the php manual.<|eor|><|eols|><|endoftext|>
10
lolphp
InconsiderateBastard
c9q054m
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>The chart makes it look confusing, but it's quite easy (for the most part). 0, '0', false, null, "", array() -> false everything else -> true The real gotchas are usually stringed integers and empty arrays. Personally, I'm never comparing an empty array to anything else besides an expression. if ($array) { }<|eor|><|sor|>Null can be a bit confusing too since NULL == 0 and NULL < -INF.<|eor|><|eols|><|endoftext|>
9
lolphp
RedWingate
c9q5xub
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|> "php" == true => true 1 == true => true "php" == 1 => false what "php" == 0 => true *what*<|eor|><|sor|>(Int) "php" -> 0<|eor|><|eols|><|endoftext|>
9
lolphp
RoundTripRadio
c9ys8y3
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|> "php" == true => true 1 == true => true "php" == 1 => false what "php" == 0 => true *what*<|eor|><|sor|>Well, 1 == true 2 == true 1 != 2 The first example isn't that much of a "what".<|eor|><|eols|><|endoftext|>
9
lolphp
blueskin
c9qifi5
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>true == "php" == 0 == false<|eor|><|soopr|>My favourite: NULL < -1 < 0 < NULL and 0 > -1 .<|eoopr|><|eols|><|endoftext|>
8
lolphp
merreborn
c9q0mnj
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>If there are any loosely typed languages that don't have this problem, I'd love to hear about them. Do, for example, ruby or javascript fare much better?<|eor|><|eols|><|endoftext|>
7
lolphp
djsumdog
c9uo47w
<|sols|><|sot|>Just came across this gem... PHP comparison result chart.<|eot|><|sol|>http://www.decontextualize.com/wp-content/uploads/2010/01/php-loose-comparisons.png<|eol|><|sor|>If there are any loosely typed languages that don't have this problem, I'd love to hear about them. Do, for example, ruby or javascript fare much better?<|eor|><|sor|>generated this for javascript image: http://i.imgur.com/zdD2zsh.png source: http://codepen.io/anon/pen/Lyhek <|eor|><|sor|>Now with dazzling color: http://i.imgur.com/H2AHwtE.png source: http://codepen.io/anon/pen/jfIAw<|eor|><|sor|>The color graph is awesome, because it shows that both sides of the diagonal are symmetrical. <|eor|><|eols|><|endoftext|>
7
lolphp
Serialk
7gmn5j
<|sols|><|sot|>PHP 7.2.0 comes with numerous improvements and new features such as Counting of non-countable objects<|eot|><|sol|>http://news.php.net/php.announce/229<|eol|><|eols|><|endoftext|>
100
lolphp
Serialk
dqk36sd
<|sols|><|sot|>PHP 7.2.0 comes with numerous improvements and new features such as Counting of non-countable objects<|eot|><|sol|>http://news.php.net/php.announce/229<|eol|><|soopr|>It actually [adds a warning when you try to do that](https://wiki.php.net/rfc/counting_non_countables), but the phrasing was so bad I couldn't resist to post it here.<|eoopr|><|eols|><|endoftext|>
45
lolphp
the_alias_of_andrea
dqk5jso
<|sols|><|sot|>PHP 7.2.0 comes with numerous improvements and new features such as Counting of non-countable objects<|eot|><|sol|>http://news.php.net/php.announce/229<|eol|><|sor|>I'm slightly amused the feature at the top of the list is a bug fix by me.<|eor|><|eols|><|endoftext|>
25
lolphp
carlos_vini
dqklsp6
<|sols|><|sot|>PHP 7.2.0 comes with numerous improvements and new features such as Counting of non-countable objects<|eot|><|sol|>http://news.php.net/php.announce/229<|eol|><|soopr|>It actually [adds a warning when you try to do that](https://wiki.php.net/rfc/counting_non_countables), but the phrasing was so bad I couldn't resist to post it here.<|eoopr|><|sor|>probably copy/paste of all RFCs as "features", even tho one of them is a bug fix<|eor|><|eols|><|endoftext|>
16
lolphp
walterbanana
dql0uhx
<|sols|><|sot|>PHP 7.2.0 comes with numerous improvements and new features such as Counting of non-countable objects<|eot|><|sol|>http://news.php.net/php.announce/229<|eol|><|sor|>I'm slightly amused the feature at the top of the list is a bug fix by me.<|eor|><|sor|>Thanks for contributing<|eor|><|eols|><|endoftext|>
11
lolphp
bart2019
dqkpa1d
<|sols|><|sot|>PHP 7.2.0 comes with numerous improvements and new features such as Counting of non-countable objects<|eot|><|sol|>http://news.php.net/php.announce/229<|eol|><|sor|>And they consider "Mcrypt extension removed" as an improvement. In that case there's plenty of other improvements that I can propose.<|eor|><|eols|><|endoftext|>
9
lolphp
Serialk
dqmkne5
<|sols|><|sot|>PHP 7.2.0 comes with numerous improvements and new features such as Counting of non-countable objects<|eot|><|sol|>http://news.php.net/php.announce/229<|eol|><|sor|>And they consider "Mcrypt extension removed" as an improvement. In that case there's plenty of other improvements that I can propose.<|eor|><|sor|>Why do you think keeping Mcrypt was better?<|eor|><|soopr|>He's just saying that removing shit from the standard library is easy to do as there's just so many of it, so it's not like it's notable or anything <|eoopr|><|eols|><|endoftext|>
6
lolphp
Takeoded
dr9eljz
<|sols|><|sot|>PHP 7.2.0 comes with numerous improvements and new features such as Counting of non-countable objects<|eot|><|sol|>http://news.php.net/php.announce/229<|eol|><|sor|>And they consider "Mcrypt extension removed" as an improvement. In that case there's plenty of other improvements that I can propose.<|eor|><|sor|>Why do you think keeping Mcrypt was better?<|eor|><|sor|>personally i don't, but i don't like the mcrypt removal RFC, it says there's something wrong with using the Serpent cipher. this is not even remotely true: `Most cryptography experts would consider their inclusion in any software written in 2016 to be a code smell`<|eor|><|sor|>How many cryptography experts have you consulted with to back up your claim that "this is not even remotely true"?<|eor|><|sor|>none, but when was the last time you heard somebody badmouthing Serpent? (1999, it's slower than Rijndael), and it has an excellent track record, after 19 years, the best we can do is a computationally infeasible attack on 12 rounds, out of 32.<|eor|><|sor|>When was the last time you heard someone analyzing Serpent? It has large S-Boxes and is probably vulnerable to cache-timing attacks like AES is. Nobody has bothered to study this because very few things actually use Serpent. AES's saving grace is hardware support (AES-NI). [And yes, those matter!](https://crypto.stackexchange.com/questions/5526/aes-timing-attacks)<|eor|><|sor|>> When was the last time you heard someone analyzing Serpent? [2011,](http://www3.ntu.edu.sg/home/wuhj/research/publications/2011_ACISP_MLC.pdf) see section 5. > Nobody has bothered to study this wrong, keep reading. > probably vulnerable to cache-timing attacks like AES wrong: > In the AES context, one possible timing attack would be > on the data dependent rotations used, for example, in RC6; most smartcard > processors support only a single bit shift, so a variable shift will typically be > implemented as multiple single bit shifts in a loop. It is possible to design a > constant time implementation, but this imposes a performance penalty. > ***In the case of Serpent, the number of instructions used to encrypt or decrypt > does not depend on either the data or the key, and even cache accesses cannot > help the attacker as we do not access different locations in memory for different > plaintexts or keys. It follows that timing attacks are not applicable.*** [(src, section 4)](https://www.cl.cam.ac.uk/~rja14/Papers/serpent_card_final.pdf) <|eor|><|eols|><|endoftext|>
5
lolphp
Name0fTheUser
62ziz4
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|eols|><|endoftext|>
101
lolphp
Vakieh
dfq8v23
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>This sums up the entire reason PHP is shit, and why python and javascript are destroying it as the 'static typed languages are too difficult' languages of choice. The developers have exactly zero balls to do what needs to be done. If you have to break the shit out of dodgy code to fix your language, you break it. Otherwise the best anyone can do is shit. This is the funniest thing I have seen in weeks!<|eor|><|eols|><|endoftext|>
27
lolphp
Iascan
dfqw8jt
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>Gettype Forhistorical reasons"double" is returned in case of a float, and not simply "float" Oh my<|eor|><|eols|><|endoftext|>
23
lolphp
bregottextrasaltat
dfrnwsu
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>This sums up the entire reason PHP is shit, and why python and javascript are destroying it as the 'static typed languages are too difficult' languages of choice. The developers have exactly zero balls to do what needs to be done. If you have to break the shit out of dodgy code to fix your language, you break it. Otherwise the best anyone can do is shit. This is the funniest thing I have seen in weeks!<|eor|><|sor|>>javascript >serverside no thanks<|eor|><|sor|>Did you see this year's StackOverflow survey? NodeJS/Express is quite possibly on its way to being the industry standard. Remember though that you don't need to worry about browser compatibility with serverside JS, which means you can use as pure an ES6 and soon 7 as Node allows at any given moment. Strong typing, annotations/decorators, classes, dependency injection... it's like js grew up.<|eor|><|sor|>still gross, js is gross to begin with<|eor|><|eols|><|endoftext|>
19
lolphp
Vakieh
dfsczl5
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>Gettype Forhistorical reasons"double" is returned in case of a float, and not simply "float" Oh my<|eor|><|sor|>They think if they document their shit functionality that it somehow justifies it all<|eor|><|sor|>So, how would you fix this oversight? suddenly return `"float"` and break existing scripts ("php xx is such a piece of shit - I've upgraded and now my site is broken")? Create `gettype_real()` ("haha - php is such a piece of shit - it has both a broken and a working gettype() function"). Ah! I know. Don't make mistakes to start with. Then you're never in this situation between a rock and a hard place. Easy! Of course then people will yell at you for never including their pet features, but at least you won't be laughed at.<|eor|><|sor|>Return "float" by default, have a --legacy-gettype argument which uses the old code, but also throws up a scary sounding deprecated warning that the old code is no longer maintained. You know, like a normal breaking change is handled.<|eor|><|eols|><|endoftext|>
17
lolphp
bregottextrasaltat
dfrn16d
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>This sums up the entire reason PHP is shit, and why python and javascript are destroying it as the 'static typed languages are too difficult' languages of choice. The developers have exactly zero balls to do what needs to be done. If you have to break the shit out of dodgy code to fix your language, you break it. Otherwise the best anyone can do is shit. This is the funniest thing I have seen in weeks!<|eor|><|sor|>>javascript >serverside no thanks<|eor|><|eols|><|endoftext|>
16
lolphp
Vakieh
dfrrydn
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>>javascript >serverside no thanks<|eor|><|sor|>Did you see this year's StackOverflow survey? NodeJS/Express is quite possibly on its way to being the industry standard. Remember though that you don't need to worry about browser compatibility with serverside JS, which means you can use as pure an ES6 and soon 7 as Node allows at any given moment. Strong typing, annotations/decorators, classes, dependency injection... it's like js grew up.<|eor|><|sor|>still gross, js is gross to begin with<|eor|><|sor|>Python 1 looked pretty shithouse, and the migration from 2 to 3 is a poster child for what not to do. Show me a language and I'll point out how shitty it used to be. ES3 should have involved criminal charges, ES5 is about as bad as PHP, but ES6 is solid.<|eor|><|sor|>they're still descendants though, i'd never be able to learn pure es6 and still be compatible with browser stuff<|eor|><|sor|>Sure you can - it's called Typescript.<|eor|><|sor|>nah i can really only hold one language in my head at the same time, and if i go on vacation for a couple of weeks then i've forgotten most of it been using php almost daily since 2005 and it still disappears<|eor|><|sor|>Sounds like a you problem.<|eor|><|eols|><|endoftext|>
11
lolphp
shvelo
dfri298
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>[site:php.net real](https://www.google.com/search?q=site%3Aphp.net+intext%3Areal#q=site:php.net+real&*)<|eor|><|eols|><|endoftext|>
10
lolphp
Vakieh
dfrnviw
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>This sums up the entire reason PHP is shit, and why python and javascript are destroying it as the 'static typed languages are too difficult' languages of choice. The developers have exactly zero balls to do what needs to be done. If you have to break the shit out of dodgy code to fix your language, you break it. Otherwise the best anyone can do is shit. This is the funniest thing I have seen in weeks!<|eor|><|sor|>>javascript >serverside no thanks<|eor|><|sor|>Did you see this year's StackOverflow survey? NodeJS/Express is quite possibly on its way to being the industry standard. Remember though that you don't need to worry about browser compatibility with serverside JS, which means you can use as pure an ES6 and soon 7 as Node allows at any given moment. Strong typing, annotations/decorators, classes, dependency injection... it's like js grew up.<|eor|><|eols|><|endoftext|>
10
lolphp
Vacation_Flu
dfshshz
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>Gettype Forhistorical reasons"double" is returned in case of a float, and not simply "float" Oh my<|eor|><|sor|>They think if they document their shit functionality that it somehow justifies it all<|eor|><|sor|>So, how would you fix this oversight? suddenly return `"float"` and break existing scripts ("php xx is such a piece of shit - I've upgraded and now my site is broken")? Create `gettype_real()` ("haha - php is such a piece of shit - it has both a broken and a working gettype() function"). Ah! I know. Don't make mistakes to start with. Then you're never in this situation between a rock and a hard place. Easy! Of course then people will yell at you for never including their pet features, but at least you won't be laughed at.<|eor|><|sor|>Semantic versioning shows us the way. Fix it in the next major breaking release, and it's up to developers to properly test their shit. For PHP developers who don't understand what I just said, "testing" is when you write extra code that has one job: make sure your code does what it's supposed to.<|eor|><|eols|><|endoftext|>
7
lolphp
Vakieh
dfron2r
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>This sums up the entire reason PHP is shit, and why python and javascript are destroying it as the 'static typed languages are too difficult' languages of choice. The developers have exactly zero balls to do what needs to be done. If you have to break the shit out of dodgy code to fix your language, you break it. Otherwise the best anyone can do is shit. This is the funniest thing I have seen in weeks!<|eor|><|sor|>>javascript >serverside no thanks<|eor|><|sor|>Did you see this year's StackOverflow survey? NodeJS/Express is quite possibly on its way to being the industry standard. Remember though that you don't need to worry about browser compatibility with serverside JS, which means you can use as pure an ES6 and soon 7 as Node allows at any given moment. Strong typing, annotations/decorators, classes, dependency injection... it's like js grew up.<|eor|><|sor|>still gross, js is gross to begin with<|eor|><|sor|>Python 1 looked pretty shithouse, and the migration from 2 to 3 is a poster child for what not to do. Show me a language and I'll point out how shitty it used to be. ES3 should have involved criminal charges, ES5 is about as bad as PHP, but ES6 is solid.<|eor|><|eols|><|endoftext|>
7
lolphp
Vacation_Flu
dfulwp5
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>Gettype Forhistorical reasons"double" is returned in case of a float, and not simply "float" Oh my<|eor|><|sor|>They think if they document their shit functionality that it somehow justifies it all<|eor|><|sor|>So, how would you fix this oversight? suddenly return `"float"` and break existing scripts ("php xx is such a piece of shit - I've upgraded and now my site is broken")? Create `gettype_real()` ("haha - php is such a piece of shit - it has both a broken and a working gettype() function"). Ah! I know. Don't make mistakes to start with. Then you're never in this situation between a rock and a hard place. Easy! Of course then people will yell at you for never including their pet features, but at least you won't be laughed at.<|eor|><|sor|>Semantic versioning shows us the way. Fix it in the next major breaking release, and it's up to developers to properly test their shit. For PHP developers who don't understand what I just said, "testing" is when you write extra code that has one job: make sure your code does what it's supposed to.<|eor|><|sor|>> Fix it in the next major breaking release, and it's up to developers to properly test their shit. Like Python 3? 10 years after it came out, 2.7 is still the most widely used release. <|eor|><|sor|>Not sure what point you're trying to make. Are you claiming that because the Python 3 release was botched, semantic versioning for breaking changes isn't possible or a good idea?<|eor|><|sor|>I'm saying that breaking changes hinder adoption, even more so, subtly breaking changes. <|eor|><|sor|>Yes, breaking changes have that effect. But they're necessary, and PHP is a good example of what happens when developers are afraid to make breaking changes.<|eor|><|eols|><|endoftext|>
7
lolphp
tfidry
dfvz56w
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>This sums up the entire reason PHP is shit, and why python and javascript are destroying it as the 'static typed languages are too difficult' languages of choice. The developers have exactly zero balls to do what needs to be done. If you have to break the shit out of dodgy code to fix your language, you break it. Otherwise the best anyone can do is shit. This is the funniest thing I have seen in weeks!<|eor|><|sor|>Lol man. Seriously I can understand some people complaining about PHP being shit here, but don't dare to come out with JS... It's the pot calling the kettle black. Judging from your thread below let me give you quite a few reasons: - First SO: ok I didn't know SO was a reliable source to express the industry adoption. AFAIK most of the big players using nodejs are using it for a very small portion, precisely because JS is quite unstable/shit. It just had the strange vertue to be hype. And by experience: even companies using it extensively, tend to cry. - The language is poorly designed. You can trash PHP all you want, JS is even worse. - As a language, JS is way more complex: mixed of OOP and FP. Quite powerful I must say, and once you mastered it I can understand you can find it pleasant, but it still makes it much harder to use properly and having thousands of libs where you having a weird inconsistent mix of OOP/FP just makes it weirder. - The ecosystem is the very definition of immature and unstable: - Semver is not widely adopted. Even when it is in practice there is a lot, lot of mistakes breaking semver making it quite ineffective. Also there is little good tooling for proper deprecations and providing smooth upgrades. - Micro packages everywhere and 100 packages to do the same godamn thing, all done differently, all with a very high truck factor, inconsistency in maintenance efforts. Do a few good popular and well-maintained libraries instead of 100 poor quality ones. And learn the cost of introducing a dependency. Left-pad is a good lesson, but it's sad that this needed to happen to make people realise that can be an issue. - JS is very bad for you server/browser memory/CPU. Just way too greedy... - JS is one of the rare language able to give you shittier errors than PHP: like absolutely random, not helpful the least. - Security and DX is always an afterthought. Ironic to say that in this subreddit I must say. - New versions every months and multiple engines: how to introduce pressure at the lowest level. Now it's not enough to have to deal with the language, you must focus on upgrading and dealing will all the implementation quirks (because yes, there is issues from one engine to another or one version to another, like non-documented ones) instead of being able to have something working and spend your time building applications. That's a raw bunch of ideas. And just to clarify, I'm using JS & TypeScript extensively, but I can't help but to find it to be a real piece of shit. And don't get me started for the front-end, it's like 10x worse. JS is a powerful tool, but if you love it, you've got a toxic relationship.<|eor|><|eols|><|endoftext|>
6
lolphp
Pat55word
dfrn06v
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>Gettype Forhistorical reasons"double" is returned in case of a float, and not simply "float" Oh my<|eor|><|sor|>They think if they document their shit functionality that it somehow justifies it all<|eor|><|sor|>So, how would you fix this oversight? suddenly return `"float"` and break existing scripts ("php xx is such a piece of shit - I've upgraded and now my site is broken")? Create `gettype_real()` ("haha - php is such a piece of shit - it has both a broken and a working gettype() function"). Ah! I know. Don't make mistakes to start with. Then you're never in this situation between a rock and a hard place. Easy! Of course then people will yell at you for never including their pet features, but at least you won't be laughed at.<|eor|><|sor|>"Suddenly" - only once they've updated their php version. Though the longer you leave bugs in "for historical reasons" the worse this problem would be. The correct thing to do is asap fix the bug to minimise impact. Relying on the behaviour of buggy code is a mistake in any instance<|eor|><|eols|><|endoftext|>
6
lolphp
TheSkyNet
dft4exb
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>This sums up the entire reason PHP is shit, and why python and javascript are destroying it as the 'static typed languages are too difficult' languages of choice. The developers have exactly zero balls to do what needs to be done. If you have to break the shit out of dodgy code to fix your language, you break it. Otherwise the best anyone can do is shit. This is the funniest thing I have seen in weeks!<|eor|><|sor|>>javascript >serverside no thanks<|eor|><|sor|>Did you see this year's StackOverflow survey? NodeJS/Express is quite possibly on its way to being the industry standard. Remember though that you don't need to worry about browser compatibility with serverside JS, which means you can use as pure an ES6 and soon 7 as Node allows at any given moment. Strong typing, annotations/decorators, classes, dependency injection... it's like js grew up.<|eor|><|sor|>The only thing worse than php on the server is JavaScript on the server it has most of the same drawbacks and a more volatile ecosystem.<|eor|><|eols|><|endoftext|>
6
lolphp
pilif
dfroarp
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>Gettype Forhistorical reasons"double" is returned in case of a float, and not simply "float" Oh my<|eor|><|sor|>They think if they document their shit functionality that it somehow justifies it all<|eor|><|sor|>So, how would you fix this oversight? suddenly return `"float"` and break existing scripts ("php xx is such a piece of shit - I've upgraded and now my site is broken")? Create `gettype_real()` ("haha - php is such a piece of shit - it has both a broken and a working gettype() function"). Ah! I know. Don't make mistakes to start with. Then you're never in this situation between a rock and a hard place. Easy! Of course then people will yell at you for never including their pet features, but at least you won't be laughed at.<|eor|><|sor|>[deleted]<|eor|><|sor|>Two things: - more thought went into the initial release to gain enough usage in the public to the point where this becomes significant - much lower user-counts than PHP, so the cost of breaking everything is smaller.<|eor|><|eols|><|endoftext|>
6
lolphp
theRealSteinberg
dg090n1
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>This sums up the entire reason PHP is shit, and why python and javascript are destroying it as the 'static typed languages are too difficult' languages of choice. The developers have exactly zero balls to do what needs to be done. If you have to break the shit out of dodgy code to fix your language, you break it. Otherwise the best anyone can do is shit. This is the funniest thing I have seen in weeks!<|eor|><|sor|>>javascript >serverside no thanks<|eor|><|sor|>Did you see this year's StackOverflow survey? NodeJS/Express is quite possibly on its way to being the industry standard. Remember though that you don't need to worry about browser compatibility with serverside JS, which means you can use as pure an ES6 and soon 7 as Node allows at any given moment. Strong typing, annotations/decorators, classes, dependency injection... it's like js grew up.<|eor|><|sor|>still gross, js is gross to begin with<|eor|><|sor|>Python 1 looked pretty shithouse, and the migration from 2 to 3 is a poster child for what not to do. Show me a language and I'll point out how shitty it used to be. ES3 should have involved criminal charges, ES5 is about as bad as PHP, but ES6 is solid.<|eor|><|sor|>> Show me a language and I'll point out how shitty it used to be. Is that web languages only or any language?<|eor|><|eols|><|endoftext|>
6
lolphp
kr094
dfqlzwk
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>This sums up the entire reason PHP is shit, and why python and javascript are destroying it as the 'static typed languages are too difficult' languages of choice. The developers have exactly zero balls to do what needs to be done. If you have to break the shit out of dodgy code to fix your language, you break it. Otherwise the best anyone can do is shit. This is the funniest thing I have seen in weeks!<|eor|><|sor|>Judging from the looks the pages found [here](https://pecl.php.net/package/ereg), I think the authors are worried about their shitty php sites breaking<|eor|><|eols|><|endoftext|>
5
lolphp
Vacation_Flu
dfuy3sq
<|sols|><|sot|>site:php.net intext:historical reasons<|eot|><|sol|>https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eol|><|sor|>> Fix it in the next major breaking release, and it's up to developers to properly test their shit. Like Python 3? 10 years after it came out, 2.7 is still the most widely used release. <|eor|><|sor|>Not sure what point you're trying to make. Are you claiming that because the Python 3 release was botched, semantic versioning for breaking changes isn't possible or a good idea?<|eor|><|sor|>I'm saying that breaking changes hinder adoption, even more so, subtly breaking changes. <|eor|><|sor|>Yes, breaking changes have that effect. But they're necessary, and PHP is a good example of what happens when developers are afraid to make breaking changes.<|eor|><|sor|>what? Huge world-wide adoption? Being used in 2 of the top 4 websites in the world? Yeah - that's a terrible outcome. Oh you mean people laughing at the language's expense? Oh well. Could be worse :p /s<|eor|><|sor|>Given the subreddit you're in, I find it amusing you have to fall back on "so what if it sucks to work with, it's popular".<|eor|><|sor|>I'm not. I agree that this stuff is ridiculous. I also agree that PHP is a horrible language. But I also understand that there are advantages for prioritising backwards compatibility. <|eor|><|sor|>No shit there's advantages. But the PHP people have taken it to such a ludicrous extreme that the language is a dumpster fire of unfixable bugs that feels like a punishment for using GOTOs in a previous life. <|eor|><|eols|><|endoftext|>
5
lolphp
SerdanKK
d4o2v9
<|sols|><|sot|>PHP is whitespace insensitive, except when it isn't.<|eot|><|sol|>https://i.redd.it/z4uixvzsssm31.png<|eol|><|eols|><|endoftext|>
98
lolphp
nikic
f0f3h3m
<|sols|><|sot|>PHP is whitespace insensitive, except when it isn't.<|eot|><|sol|>https://i.redd.it/z4uixvzsssm31.png<|eol|><|sor|>Whitespace insensitive means that multiple whitespace characters can be collapsed into one. Not that whitespace can be removed entirely. Consider a trivial case like `return foo;`. Replacing that with `returnfoo;` will break in every language. I agree though that the whitespace requirement after `<?php` is somewhat odd.<|eor|><|eols|><|endoftext|>
50
lolphp
SirClueless
f0f7cz2
<|sols|><|sot|>PHP is whitespace insensitive, except when it isn't.<|eot|><|sol|>https://i.redd.it/z4uixvzsssm31.png<|eol|><|sor|>Whitespace insensitive means that multiple whitespace characters can be collapsed into one. Not that whitespace can be removed entirely. Consider a trivial case like `return foo;`. Replacing that with `returnfoo;` will break in every language. I agree though that the whitespace requirement after `<?php` is somewhat odd.<|eor|><|sor|>I would say "whitespace insensitive" also applies to syntax elements that can be optionally surrounded with whitespace like `}` `;` `=` `()`, etc. The fact that `if($x==1){}` parses the same as `if ( $x == 1 ) { }` is an example of being insensitive to whitespace around most punctuation characters. But of course PHP isn't universally "whitespace insensitive" in this regard: `if ($ x == 1) {}` is a syntax error, for example. The special requirements around the opening `<?php` tag are just one case of this.<|eor|><|eols|><|endoftext|>
16
lolphp
SerdanKK
f0enq30
<|sols|><|sot|>PHP is whitespace insensitive, except when it isn't.<|eot|><|sol|>https://i.redd.it/z4uixvzsssm31.png<|eol|><|soopr|>PhpStorm doesn't catch this. Half of the online sandboxes I tested displayed the above behaviour (e.g. [http://phpfiddle.org/](http://phpfiddle.org/)) and the rest threw an error.<|eoopr|><|eols|><|endoftext|>
13
lolphp
timmyotc
f0ezw1u
<|sols|><|sot|>PHP is whitespace insensitive, except when it isn't.<|eot|><|sol|>https://i.redd.it/z4uixvzsssm31.png<|eol|><|sor|>Thats because you are using the wrong syntax for if statements in html When using : <?php if (true): ?> <div>Hello</div> <?php endif ?> <?php if (false): ?> <div>SECRET</div> <?php endif ?> It outputs only the expected div https://www.php.net/manual/en/control-structures.alternative-syntax.php<|eor|><|sor|>Nevermind your syntax is also valid.. TIL :p But the problem is the fifth line: <?php} A space or newline between php and } fixes the problem, i think it is because it sees it as one symbol, and therefore not running the code because there is no php opening tag<|eor|><|sor|>It's as if the title was accurate in the first place.<|eor|><|eols|><|endoftext|>
13