subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
cleeder
dzifx26
<|soss|><|sot|>I thought we were past this<|eot|><|sost|> <?php var_dump(array(0 => ':p1') == array(0 => 0)); // bool(true) Ten years and this language is still finding ways to kick me in the nuts. I mean, I get it. An array is equal if its keys and elements are equal. And `:p1` is, in the PHP sense, equal to 0. But still.<|eost|><|sor|>For the record, you want to use `===`, which will check types rather than coerce them in comparisons. php > var_dump(array(0 => ':p1') === array(0 => 0)); php shell code:1: bool(false) php > var_dump(array(0 => ':p1') === array(0 => ':p1')); php shell code:1: bool(true) Still an lolphp in my book, but you should probably just use `===` across the board in PHP. Forget that `==` is even a thing. Equivalently, `!==` vs `!=`. If you find yourself needing type coercion in your comparison, then and _only then_ should you use `==` or `!=`<|eor|><|eoss|><|endoftext|>
15
lolphp
creativeMan
dzic1bs
<|soss|><|sot|>I thought we were past this<|eot|><|sost|> <?php var_dump(array(0 => ':p1') == array(0 => 0)); // bool(true) Ten years and this language is still finding ways to kick me in the nuts. I mean, I get it. An array is equal if its keys and elements are equal. And `:p1` is, in the PHP sense, equal to 0. But still.<|eost|><|sor|>Why is :p1 equal to 0?<|eor|><|eoss|><|endoftext|>
10
lolphp
cleeder
dzifdv9
<|soss|><|sot|>I thought we were past this<|eot|><|sost|> <?php var_dump(array(0 => ':p1') == array(0 => 0)); // bool(true) Ten years and this language is still finding ways to kick me in the nuts. I mean, I get it. An array is equal if its keys and elements are equal. And `:p1` is, in the PHP sense, equal to 0. But still.<|eost|><|sor|>Why is :p1 equal to 0?<|eor|><|sor|>> When a string is evaluated in a numeric context, the resulting value and type are determined as follows. [..] The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). - https://secure.php.net/manual/en/language.types.string.php#language.types.string.conversion Op used `==`, which means the values of the array will be coerced when compared. `:p1` vs `0` will coerce `:p1` down to an integer, which by the rules above will evaluate to `0`.<|eor|><|eoss|><|endoftext|>
9
lolphp
ryselis
dzo7qw3
<|soss|><|sot|>I thought we were past this<|eot|><|sost|> <?php var_dump(array(0 => ':p1') == array(0 => 0)); // bool(true) Ten years and this language is still finding ways to kick me in the nuts. I mean, I get it. An array is equal if its keys and elements are equal. And `:p1` is, in the PHP sense, equal to 0. But still.<|eost|><|sor|>For the record, you want to use `===`, which will check types rather than coerce them in comparisons. php > var_dump(array(0 => ':p1') === array(0 => 0)); php shell code:1: bool(false) php > var_dump(array(0 => ':p1') === array(0 => ':p1')); php shell code:1: bool(true) Still an lolphp in my book, but you should probably just use `===` across the board in PHP. Forget that `==` is even a thing. Equivalently, `!==` vs `!=`. If you find yourself needing type coercion in your comparison, then and _only then_ should you use `==` or `!=`<|eor|><|sor|>What about greater and less than operators (< and >) ?<|eor|><|sor|>Then you're fucked. Don't compare things with these that have to be coerced. They work on the same principal as `==`.<|eor|><|sor|>It is worse than that. Sort functions use == inside.<|eor|><|eoss|><|endoftext|>
7
lolphp
SockPants
dziieek
<|soss|><|sot|>I thought we were past this<|eot|><|sost|> <?php var_dump(array(0 => ':p1') == array(0 => 0)); // bool(true) Ten years and this language is still finding ways to kick me in the nuts. I mean, I get it. An array is equal if its keys and elements are equal. And `:p1` is, in the PHP sense, equal to 0. But still.<|eost|><|sor|>For the record, you want to use `===`, which will check types rather than coerce them in comparisons. php > var_dump(array(0 => ':p1') === array(0 => 0)); php shell code:1: bool(false) php > var_dump(array(0 => ':p1') === array(0 => ':p1')); php shell code:1: bool(true) Still an lolphp in my book, but you should probably just use `===` across the board in PHP. Forget that `==` is even a thing. Equivalently, `!==` vs `!=`. If you find yourself needing type coercion in your comparison, then and _only then_ should you use `==` or `!=`<|eor|><|sor|>Yeah "this language is still finding ways to kick me in the nuts" my ass, who uses `==` anymore it's 2018 people.<|eor|><|eoss|><|endoftext|>
6
lolphp
maweki
dzils66
<|soss|><|sot|>I thought we were past this<|eot|><|sost|> <?php var_dump(array(0 => ':p1') == array(0 => 0)); // bool(true) Ten years and this language is still finding ways to kick me in the nuts. I mean, I get it. An array is equal if its keys and elements are equal. And `:p1` is, in the PHP sense, equal to 0. But still.<|eost|><|sor|>For the record, you want to use `===`, which will check types rather than coerce them in comparisons. php > var_dump(array(0 => ':p1') === array(0 => 0)); php shell code:1: bool(false) php > var_dump(array(0 => ':p1') === array(0 => ':p1')); php shell code:1: bool(true) Still an lolphp in my book, but you should probably just use `===` across the board in PHP. Forget that `==` is even a thing. Equivalently, `!==` vs `!=`. If you find yourself needing type coercion in your comparison, then and _only then_ should you use `==` or `!=`<|eor|><|sor|>doesn't `===` have different semantics on objects? I thought on objects this would make an object-equality-check instead of value equality.<|eor|><|eoss|><|endoftext|>
5
lolphp
cleeder
dzimd51
<|soss|><|sot|>I thought we were past this<|eot|><|sost|> <?php var_dump(array(0 => ':p1') == array(0 => 0)); // bool(true) Ten years and this language is still finding ways to kick me in the nuts. I mean, I get it. An array is equal if its keys and elements are equal. And `:p1` is, in the PHP sense, equal to 0. But still.<|eost|><|sor|>For the record, you want to use `===`, which will check types rather than coerce them in comparisons. php > var_dump(array(0 => ':p1') === array(0 => 0)); php shell code:1: bool(false) php > var_dump(array(0 => ':p1') === array(0 => ':p1')); php shell code:1: bool(true) Still an lolphp in my book, but you should probably just use `===` across the board in PHP. Forget that `==` is even a thing. Equivalently, `!==` vs `!=`. If you find yourself needing type coercion in your comparison, then and _only then_ should you use `==` or `!=`<|eor|><|sor|>doesn't `===` have different semantics on objects? I thought on objects this would make an object-equality-check instead of value equality.<|eor|><|sor|>Actually, yes. You are correct. `==` will check equality, where as `===` would check that both of the operands point to the same object. This would be a valid use case for `==`<|eor|><|eoss|><|endoftext|>
5
lolphp
LongDistanceEjcltr
8hn4vx
<|sols|><|sot|>`null["foo"] === null`in practice<|eot|><|sol|>https://3v4l.org/WYhto<|eol|><|eols|><|endoftext|>
16
lolphp
mhaendler
dykzdw8
<|sols|><|sot|>`null["foo"] === null`in practice<|eot|><|sol|>https://3v4l.org/WYhto<|eol|><|sor|> <?php $intNumber = 1; $stringNumber = '1'; var_dump(chr($intNumber[0] + 100)); var_dump(chr($stringNumber[0] + 100)); Thats totally understandable You want to get access the first element / pointer array, which unfortunately is an integer = NULL You want to get access of the first "element" of the string which is: 1 So we got: NULL + 100 = 100 1 + 100 = 101 chr(100) = d chr(101) = e Dont see the point here, PHP is dirty and we all love it <3<|eor|><|eols|><|endoftext|>
10
lolphp
LongDistanceEjcltr
dyl2ylj
<|sols|><|sot|>`null["foo"] === null`in practice<|eot|><|sol|>https://3v4l.org/WYhto<|eol|><|sor|> <?php $intNumber = 1; $stringNumber = '1'; var_dump(chr($intNumber[0] + 100)); var_dump(chr($stringNumber[0] + 100)); Thats totally understandable You want to get access the first element / pointer array, which unfortunately is an integer = NULL You want to get access of the first "element" of the string which is: 1 So we got: NULL + 100 = 100 1 + 100 = 101 chr(100) = d chr(101) = e Dont see the point here, PHP is dirty and we all love it <3<|eor|><|sor|>It is a bit weird that it doesnt die (I know, php is really hard to kill and stretches every conversion rule possible to survive), but I hope it at least throws a warning in the log<|eor|><|soopr|>That's the point. It doesn't throw anything. It doesn't produce warnings or notices. The net effect is that if you send '12345' into a function, you get a perfectly valid return value, but if you use 12345, you get a perfectly invalid return value. It's weak typing at its worst.<|eoopr|><|eols|><|endoftext|>
9
lolphp
Joniator
dyl0rzz
<|sols|><|sot|>`null["foo"] === null`in practice<|eot|><|sol|>https://3v4l.org/WYhto<|eol|><|sor|> <?php $intNumber = 1; $stringNumber = '1'; var_dump(chr($intNumber[0] + 100)); var_dump(chr($stringNumber[0] + 100)); Thats totally understandable You want to get access the first element / pointer array, which unfortunately is an integer = NULL You want to get access of the first "element" of the string which is: 1 So we got: NULL + 100 = 100 1 + 100 = 101 chr(100) = d chr(101) = e Dont see the point here, PHP is dirty and we all love it <3<|eor|><|sor|>It is a bit weird that it doesnt die (I know, php is really hard to kill and stretches every conversion rule possible to survive), but I hope it at least throws a warning in the log<|eor|><|eols|><|endoftext|>
6
lolphp
mikeputerbaugh
dylcduk
<|sols|><|sot|>`null["foo"] === null`in practice<|eot|><|sol|>https://3v4l.org/WYhto<|eol|><|sor|> <?php $intNumber = 1; $stringNumber = '1'; var_dump(chr($intNumber[0] + 100)); var_dump(chr($stringNumber[0] + 100)); Thats totally understandable You want to get access the first element / pointer array, which unfortunately is an integer = NULL You want to get access of the first "element" of the string which is: 1 So we got: NULL + 100 = 100 1 + 100 = 101 chr(100) = d chr(101) = e Dont see the point here, PHP is dirty and we all love it <3<|eor|><|sor|>It is a bit weird that it doesnt die (I know, php is really hard to kill and stretches every conversion rule possible to survive), but I hope it at least throws a warning in the log<|eor|><|soopr|>That's the point. It doesn't throw anything. It doesn't produce warnings or notices. The net effect is that if you send '12345' into a function, you get a perfectly valid return value, but if you use 12345, you get a perfectly invalid return value. It's weak typing at its worst.<|eoopr|><|sor|> function dumbFunction(string $arg) { ... } will coerce the argument to a string so the array indexing behavior works as intended, or <?php declare(strict_types=1); function dumbFunction(string $arg) { ... } will throw a fatal TypeError at runtime if $arg is not a string type. <|eor|><|eols|><|endoftext|>
5
lolphp
ErikkW77
6533gk
<|soss|><|sot|>PHP is finally getting closures!<|eot|><|sost|>Except that it is not. Hello all. I'm new here and to reddit, but I always read you! A friend that is more involved than me in the PHP world told me PHP would finally get closures. ($a, $b) => $a * $b He was so excited until I made him notice that it's still just anonymous functions... or rather, still not closures. Yes, you read correctly: they are adding a new syntax and a new feature that doesn't solve anything. Roughly speaking, variables in the super scopes are copied in the lambda scope rather than being inherited. Unlike what happens with any other language that claims to support closures. let a = [0, 1, 2, 3, 4, 5, 6, 7]; let removed = 0; let limit = 7; a.filter((v) => (removed += v) > limit); This simple example (JS) will not be possible with PHP. Because the lambda scope would write to a copy of "removed", not the original one. So, this is it. Prepare yourself for more hate. JS works.<|eost|><|eoss|><|endoftext|>
16
lolphp
ealf
dg7cb0n
<|soss|><|sot|>PHP is finally getting closures!<|eot|><|sost|>Except that it is not. Hello all. I'm new here and to reddit, but I always read you! A friend that is more involved than me in the PHP world told me PHP would finally get closures. ($a, $b) => $a * $b He was so excited until I made him notice that it's still just anonymous functions... or rather, still not closures. Yes, you read correctly: they are adding a new syntax and a new feature that doesn't solve anything. Roughly speaking, variables in the super scopes are copied in the lambda scope rather than being inherited. Unlike what happens with any other language that claims to support closures. let a = [0, 1, 2, 3, 4, 5, 6, 7]; let removed = 0; let limit = 7; a.filter((v) => (removed += v) > limit); This simple example (JS) will not be possible with PHP. Because the lambda scope would write to a copy of "removed", not the original one. So, this is it. Prepare yourself for more hate. JS works.<|eost|><|sor|>`function() use(&$var)` has worked since 2009.<|eor|><|eoss|><|endoftext|>
45
lolphp
zvax
dg784pu
<|soss|><|sot|>PHP is finally getting closures!<|eot|><|sost|>Except that it is not. Hello all. I'm new here and to reddit, but I always read you! A friend that is more involved than me in the PHP world told me PHP would finally get closures. ($a, $b) => $a * $b He was so excited until I made him notice that it's still just anonymous functions... or rather, still not closures. Yes, you read correctly: they are adding a new syntax and a new feature that doesn't solve anything. Roughly speaking, variables in the super scopes are copied in the lambda scope rather than being inherited. Unlike what happens with any other language that claims to support closures. let a = [0, 1, 2, 3, 4, 5, 6, 7]; let removed = 0; let limit = 7; a.filter((v) => (removed += v) > limit); This simple example (JS) will not be possible with PHP. Because the lambda scope would write to a copy of "removed", not the original one. So, this is it. Prepare yourself for more hate. JS works.<|eost|><|sor|>I am amazed that you believe your sample of code is anything to look up to...<|eor|><|eoss|><|endoftext|>
24
lolphp
iluuu
dg790ze
<|soss|><|sot|>PHP is finally getting closures!<|eot|><|sost|>Except that it is not. Hello all. I'm new here and to reddit, but I always read you! A friend that is more involved than me in the PHP world told me PHP would finally get closures. ($a, $b) => $a * $b He was so excited until I made him notice that it's still just anonymous functions... or rather, still not closures. Yes, you read correctly: they are adding a new syntax and a new feature that doesn't solve anything. Roughly speaking, variables in the super scopes are copied in the lambda scope rather than being inherited. Unlike what happens with any other language that claims to support closures. let a = [0, 1, 2, 3, 4, 5, 6, 7]; let removed = 0; let limit = 7; a.filter((v) => (removed += v) > limit); This simple example (JS) will not be possible with PHP. Because the lambda scope would write to a copy of "removed", not the original one. So, this is it. Prepare yourself for more hate. JS works.<|eost|><|sor|>Yeah but why would you write a single line closure that is impure? Closures already exist in PHP and they can capture variables by reference too. If you require mutating a variable from the outer scope just use the longer syntax for that specific case.<|eor|><|eoss|><|endoftext|>
14
lolphp
jesseschalken
dg7cwz1
<|soss|><|sot|>PHP is finally getting closures!<|eot|><|sost|>Except that it is not. Hello all. I'm new here and to reddit, but I always read you! A friend that is more involved than me in the PHP world told me PHP would finally get closures. ($a, $b) => $a * $b He was so excited until I made him notice that it's still just anonymous functions... or rather, still not closures. Yes, you read correctly: they are adding a new syntax and a new feature that doesn't solve anything. Roughly speaking, variables in the super scopes are copied in the lambda scope rather than being inherited. Unlike what happens with any other language that claims to support closures. let a = [0, 1, 2, 3, 4, 5, 6, 7]; let removed = 0; let limit = 7; a.filter((v) => (removed += v) > limit); This simple example (JS) will not be possible with PHP. Because the lambda scope would write to a copy of "removed", not the original one. So, this is it. Prepare yourself for more hate. JS works.<|eost|><|sor|>Capture by value (instead of capture by ref) is a perfectly sane default. It's easier to reason about because assignments in the outer and inner functions don't affect each other, and it also has better perf because the `Closure` just needs to hold onto the captured `zvals` directly rather than boxes containing them (one less level of indirection). It makes sense that if you want slower and more complicated behaviour you have to use extra syntax (`use (&$var)`) to opt into it.<|eor|><|eoss|><|endoftext|>
13
lolphp
stumpychubbins
dg7oktx
<|soss|><|sot|>PHP is finally getting closures!<|eot|><|sost|>Except that it is not. Hello all. I'm new here and to reddit, but I always read you! A friend that is more involved than me in the PHP world told me PHP would finally get closures. ($a, $b) => $a * $b He was so excited until I made him notice that it's still just anonymous functions... or rather, still not closures. Yes, you read correctly: they are adding a new syntax and a new feature that doesn't solve anything. Roughly speaking, variables in the super scopes are copied in the lambda scope rather than being inherited. Unlike what happens with any other language that claims to support closures. let a = [0, 1, 2, 3, 4, 5, 6, 7]; let removed = 0; let limit = 7; a.filter((v) => (removed += v) > limit); This simple example (JS) will not be possible with PHP. Because the lambda scope would write to a copy of "removed", not the original one. So, this is it. Prepare yourself for more hate. JS works.<|eost|><|sor|>`function() use(&$var)` has worked since 2009.<|eor|><|sor|>`(lamda () (do-something-with var))` has worked since before my dad was born<|eor|><|eoss|><|endoftext|>
12
lolphp
the_alias_of_andrea
dg7tjml
<|soss|><|sot|>PHP is finally getting closures!<|eot|><|sost|>Except that it is not. Hello all. I'm new here and to reddit, but I always read you! A friend that is more involved than me in the PHP world told me PHP would finally get closures. ($a, $b) => $a * $b He was so excited until I made him notice that it's still just anonymous functions... or rather, still not closures. Yes, you read correctly: they are adding a new syntax and a new feature that doesn't solve anything. Roughly speaking, variables in the super scopes are copied in the lambda scope rather than being inherited. Unlike what happens with any other language that claims to support closures. let a = [0, 1, 2, 3, 4, 5, 6, 7]; let removed = 0; let limit = 7; a.filter((v) => (removed += v) > limit); This simple example (JS) will not be possible with PHP. Because the lambda scope would write to a copy of "removed", not the original one. So, this is it. Prepare yourself for more hate. JS works.<|eost|><|sor|>> ($a, $b) => $a * $b I don't know what sites your friend reads, but that's not in any coming PHP version. Also, `use` by-reference exists and works already. ---- ^(by the way, `use` by-value, the behaviour you're complaining about, is often more useful, and JS doing the opposite by default was a persistent pain point with ECMAScript 5)<|eor|><|eoss|><|endoftext|>
11
lolphp
maweki
dg77yqs
<|soss|><|sot|>PHP is finally getting closures!<|eot|><|sost|>Except that it is not. Hello all. I'm new here and to reddit, but I always read you! A friend that is more involved than me in the PHP world told me PHP would finally get closures. ($a, $b) => $a * $b He was so excited until I made him notice that it's still just anonymous functions... or rather, still not closures. Yes, you read correctly: they are adding a new syntax and a new feature that doesn't solve anything. Roughly speaking, variables in the super scopes are copied in the lambda scope rather than being inherited. Unlike what happens with any other language that claims to support closures. let a = [0, 1, 2, 3, 4, 5, 6, 7]; let removed = 0; let limit = 7; a.filter((v) => (removed += v) > limit); This simple example (JS) will not be possible with PHP. Because the lambda scope would write to a copy of "removed", not the original one. So, this is it. Prepare yourself for more hate. JS works.<|eost|><|sor|>This doesn't work in python either (well, writing to a "higher" variable. This kind of syntax doesn't exist in python). This works in languages that have a keyword for declaring variables. Those that don't implicitly declare variables new to the scope. Also, people who write mutating code as parameter to array.filter break my heart. But I am sure we will find something else completely fucked up in php's implementation. <|eor|><|eoss|><|endoftext|>
7
lolphp
gschroder
dg79bvf
<|soss|><|sot|>PHP is finally getting closures!<|eot|><|sost|>Except that it is not. Hello all. I'm new here and to reddit, but I always read you! A friend that is more involved than me in the PHP world told me PHP would finally get closures. ($a, $b) => $a * $b He was so excited until I made him notice that it's still just anonymous functions... or rather, still not closures. Yes, you read correctly: they are adding a new syntax and a new feature that doesn't solve anything. Roughly speaking, variables in the super scopes are copied in the lambda scope rather than being inherited. Unlike what happens with any other language that claims to support closures. let a = [0, 1, 2, 3, 4, 5, 6, 7]; let removed = 0; let limit = 7; a.filter((v) => (removed += v) > limit); This simple example (JS) will not be possible with PHP. Because the lambda scope would write to a copy of "removed", not the original one. So, this is it. Prepare yourself for more hate. JS works.<|eost|><|sor|>This doesn't work in python either (well, writing to a "higher" variable. This kind of syntax doesn't exist in python). This works in languages that have a keyword for declaring variables. Those that don't implicitly declare variables new to the scope. Also, people who write mutating code as parameter to array.filter break my heart. But I am sure we will find something else completely fucked up in php's implementation. <|eor|><|sor|>Could you give an example code snippet that is inexpressible in languages without a distinct syntax for variable declaration? Python closures can mutate objects in upper scopes: https://repl.it/HIGj/0<|eor|><|sor|>[deleted]<|eor|><|sor|>Ah, I see. Thanks! Python3 has the `nonlocal` keyword, without which indeed mutating the binding of a variable from outer scope would be impossible.<|eor|><|eoss|><|endoftext|>
7
lolphp
nayuki
4u9td7
<|sols|><|sot|>How we broke PHP, hacked Pornhub and earned $20,000 | Bug Bounties<|eot|><|sol|>https://www.evonide.com/how-we-broke-php-hacked-pornhub-and-earned-20000-dollar/<|eol|><|eols|><|endoftext|>
17
lolphp
thallippoli
2xw0ky
<|sols|><|sot|>Thread doesnt inherit parents working directory..<|eot|><|sol|>http://lokalhost.in/2015/03/bug-with-phps-pthreads-thread-doesnt-inherit-parents-working-directory/<|eol|><|eols|><|endoftext|>
19
lolphp
thallippoli
cp3yej7
<|sols|><|sot|>Thread doesnt inherit parents working directory..<|eot|><|sol|>http://lokalhost.in/2015/03/bug-with-phps-pthreads-thread-doesnt-inherit-parents-working-directory/<|eol|><|sor|>This is an extension. Is it an official extension from the official dev team of PHP?<|eor|><|soopr|>Are you asking if this is officially broken or unofficially broken?<|eoopr|><|eols|><|endoftext|>
42
lolphp
thelordofcheese
cp3xwzk
<|sols|><|sot|>Thread doesnt inherit parents working directory..<|eot|><|sol|>http://lokalhost.in/2015/03/bug-with-phps-pthreads-thread-doesnt-inherit-parents-working-directory/<|eol|><|sor|>This is an extension. Is it an official extension from the official dev team of PHP?<|eor|><|eols|><|endoftext|>
7
lolphp
thelordofcheese
cp3zbgn
<|sols|><|sot|>Thread doesnt inherit parents working directory..<|eot|><|sol|>http://lokalhost.in/2015/03/bug-with-phps-pthreads-thread-doesnt-inherit-parents-working-directory/<|eol|><|sor|>This is an extension. Is it an official extension from the official dev team of PHP?<|eor|><|soopr|>Are you asking if this is officially broken or unofficially broken?<|eoopr|><|sor|>lol yes that's a way of putting it<|eor|><|eols|><|endoftext|>
7
lolphp
stain_leeks
2i2px3
<|soss|><|sot|>Foreach reference<|eot|><|sost|>[http://3v4l.org/P1Omj](http://3v4l.org/P1Omj) <?php $arr = array('a', 'b'); foreach ($arr as &$a) { var_dump($a); } foreach ($arr as $a) { var_dump($a); } This probably has some explanation I'd love to learn.<|eost|><|eoss|><|endoftext|>
17
lolphp
McGlockenshire
ckya8p8
<|soss|><|sot|>Foreach reference<|eot|><|sost|>[http://3v4l.org/P1Omj](http://3v4l.org/P1Omj) <?php $arr = array('a', 'b'); foreach ($arr as &$a) { var_dump($a); } foreach ($arr as $a) { var_dump($a); } This probably has some explanation I'd love to learn.<|eost|><|sor|>`$a` is not defined before the first loop. During each entry into the first loop, `$a` is set to a reference of the current array element. This array has two elements. `$a` remains a reference to the second element in the array after the loop ends. (If it was not a reference, it would *still* retain the value of the last element.) When the second loop begins, `$a` is still a reference. The second foreach copies the first value from the array into `$a`, which is a reference to the second element of the array. This, therefore, sets the second value in the array to the first value in the array, by reference. Throw in a few [`debug_zval_dump()`](http://us2.php.net/manual/en/function.debug-zval-dump.php)s and you'll [see the transformation in action](http://3v4l.org/Reth9). PHP references are really odd and sometimes amazingly counterintuitive. Avoid them *at all costs* unless you *know* that they will solve a specific problem. Please remember that almost everything in PHP is copy-on-write and refcounted for garbage collection. Adding references *almost never* makes things faster or take less memory. See also: [this SO question](http://stackoverflow.com/questions/8220399/php-foreach-pass-by-reference-last-element-duplicating-bug) and [this explanation of foreach by the amazing nikic](http://nikic.github.io/2011/11/11/PHP-Internals-When-does-foreach-copy.html)<|eor|><|eoss|><|endoftext|>
29
lolphp
EvilTerran
ckydlym
<|soss|><|sot|>Foreach reference<|eot|><|sost|>[http://3v4l.org/P1Omj](http://3v4l.org/P1Omj) <?php $arr = array('a', 'b'); foreach ($arr as &$a) { var_dump($a); } foreach ($arr as $a) { var_dump($a); } This probably has some explanation I'd love to learn.<|eost|><|soopr|>Well, thank you, it is clear now. Turns out it's more #lolme than #lolphp :)<|eoopr|><|sor|>No, no, it's still pretty lolphp. No sane language would have anything like PHP's "references" -- scare-quotes because, well... PHP's idea of a "reference" is not like anyone else's. "Aliases" would be a much better word. But even with a better name, they'd still be a terrible idea. Arguably, a sane language would also limit the scope of the iterator variable to the body of the loop, which would also prevent this problem. For instance, perl does that (and it's not even a particularly sane language!); so do C (from C99 onwards) and C++, I believe. Anyway, for future reference (heh), I've seen this idiom used to avoid this problem: foreach ($a as &$x) { ... } unset ($x); It works because `unset()`ing a variable cuts it off from any "references".<|eor|><|eoss|><|endoftext|>
23
lolphp
stain_leeks
ckyajiq
<|soss|><|sot|>Foreach reference<|eot|><|sost|>[http://3v4l.org/P1Omj](http://3v4l.org/P1Omj) <?php $arr = array('a', 'b'); foreach ($arr as &$a) { var_dump($a); } foreach ($arr as $a) { var_dump($a); } This probably has some explanation I'd love to learn.<|eost|><|soopr|>Well, thank you, it is clear now. Turns out it's more #lolme than #lolphp :)<|eoopr|><|eoss|><|endoftext|>
7
lolphp
bart2019
ckz71kc
<|soss|><|sot|>Foreach reference<|eot|><|sost|>[http://3v4l.org/P1Omj](http://3v4l.org/P1Omj) <?php $arr = array('a', 'b'); foreach ($arr as &$a) { var_dump($a); } foreach ($arr as $a) { var_dump($a); } This probably has some explanation I'd love to learn.<|eost|><|sor|>My general rule with foreach and references is: > *always* use `unset($loopvar);` after the loop Because of shit like this: $arr = array('a', 'b'); foreach($arr as &$a) { # whatever } # best use unset($a) here... $a = 'lol'; var_dump($arr); which produces array(2) { [0]=> string(1) "a" [1]=> &string(3) "lol" } *With* `unset($a);` at the proper place, which breaks the reference link, you get: array(2) { [0]=> string(1) "a" [1]=> string(1) "b" } which is in line what normal people expect, IMHO. <|eor|><|eoss|><|endoftext|>
5
lolphp
s0ckpuppet
yomzp
<|sols|><|sot|>PHP drops World domination from the TODO (xpost)<|eot|><|sol|>https://github.com/php/php-src/commit/a90170e6f803f283d6c8e4e8d6b7bd8b7bd011a4<|eol|><|eols|><|endoftext|>
19
lolphp
vytah
c5xhhrn
<|sols|><|sot|>PHP drops World domination from the TODO (xpost)<|eot|><|sol|>https://github.com/php/php-src/commit/a90170e6f803f283d6c8e4e8d6b7bd8b7bd011a4<|eol|><|sor|>Bug description: World isn't dominated by PHP Status: CLOSED WONTFIX<|eor|><|eols|><|endoftext|>
16
lolphp
sloat
c5xifns
<|sols|><|sot|>PHP drops World domination from the TODO (xpost)<|eot|><|sol|>https://github.com/php/php-src/commit/a90170e6f803f283d6c8e4e8d6b7bd8b7bd011a4<|eol|><|sor|>Their world domination code had an XSS vulnerability in it.<|eor|><|eols|><|endoftext|>
10
lolphp
merreborn
c5xrn4t
<|sols|><|sot|>PHP drops World domination from the TODO (xpost)<|eot|><|sol|>https://github.com/php/php-src/commit/a90170e6f803f283d6c8e4e8d6b7bd8b7bd011a4<|eol|><|sor|>Ugh. I hate seeing these sorts of pages on github where the the peanut gallery shows up to comment. The comment quality isn't much better than youtube.<|eor|><|eols|><|endoftext|>
9
lolphp
nsfwIvan
c5xr40c
<|sols|><|sot|>PHP drops World domination from the TODO (xpost)<|eot|><|sol|>https://github.com/php/php-src/commit/a90170e6f803f283d6c8e4e8d6b7bd8b7bd011a4<|eol|><|sor|>Bug description: World isn't dominated by PHP Status: CLOSED WONTFIX<|eor|><|sor|>I'ts a users fault. They use php in wrong way and doing so denounce all rights to world domination.<|eor|><|eols|><|endoftext|>
5
lolphp
vytah
vga2d
<|sols|><|sot|>All timezones are equal.<|eot|><|sol|>https://bugs.php.net/bug.php?id=54655<|eol|><|eols|><|endoftext|>
17
lolphp
Porges
c54avqe
<|sols|><|sot|>All timezones are equal.<|eot|><|sol|>https://bugs.php.net/bug.php?id=54655<|eol|><|sor|>> would be nice having this working too, if possible: > > var_dump($a >= $b); > > var_dump($a <= $b); _<|eor|><|eols|><|endoftext|>
6
lolphp
vytah
c54841e
<|sols|><|sot|>All timezones are equal.<|eot|><|sol|>https://bugs.php.net/bug.php?id=54655<|eol|><|soopr|>I tested it with two more distant timezones, to check if it's some weird issue with DST. It's not: <? $a = new \DateTimeZone("Europe/Rome"); $b = new \DateTimeZone("Asia/Tokyo"); var_dump($a == $b); // bool(true) ?> <|eoopr|><|eols|><|endoftext|>
6
lolphp
sumdog
nvd8y
<|sols|><|sot|>Supercolliding PHP Array [X-Post from /r/Programming]<|eot|><|sol|>http://nikic.github.com/2011/12/28/Supercolliding-a-PHP-array.html<|eol|><|eols|><|endoftext|>
17
lolphp
nikic
c3c8500
<|sols|><|sot|>Supercolliding PHP Array [X-Post from /r/Programming]<|eot|><|sol|>http://nikic.github.com/2011/12/28/Supercolliding-a-PHP-array.html<|eol|><|sor|>Just to ensure that you got it right: This is not unique to PHP, not at all. All languages using non-randomized hashtables (which is pretty much all web languages) are vulnerable to this kind of attack.<|eor|><|eols|><|endoftext|>
7
lolphp
ealf
g61yb
<|soss|><|sot|>json_decode('hello world') === 'hello world'<|eot|><|sost|><|eost|><|eoss|><|endoftext|>
16
lolphp
ealf
c1m929d
<|soss|><|sot|>json_decode('hello world') === 'hello world'<|eot|><|sost|><|eost|><|soopr|>Also, json_decode('[') === null json_decode(' [') === ' [' <|eoopr|><|eoss|><|endoftext|>
11
lolphp
brinchj
c1nt06d
<|soss|><|sot|>json_decode('hello world') === 'hello world'<|eot|><|sost|><|eost|><|soopr|>Also, json_decode('[') === null json_decode(' [') === ' [' <|eoopr|><|sor|>And here I chose JSON because it's such a simple notation. A strict parser can be implemented in a matter of hours.<|eor|><|eoss|><|endoftext|>
5
lolphp
Takeoded
keyog2
<|soss|><|sot|>consider using fetchAll() instead of fetchAll()<|eot|><|sost|>``` $ php -r '$db = new PDO('\''mysql:host=<censored>;port=<censored>;dbname=<censored>;charset=utf8mb4'\'','\''<censored>'\'','\''<censored>'\'',array ( PDO::ATTR_EMULATE_PREPARES=> false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ));$ret=$db->query('\''DELETE FROM global_error_logs WHERE id IN (2632431);'\'')->fetchAll();unset($db);var_export($ret);' ``` &nbsp; > PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in Command line code:5 > Stack trace: > #0 Command line code(5): PDOStatement->fetchAll() > #1 {main} > thrown in Command line code on line 5 (screenshot if reddit fucks up the the formatting: https://i.imgur.com/yG4oFhE.png ) it asks me to... consider using PDOStatement::fetchAll() instead of PDOStatement::fetchAll() ! genius, why didn't i think of that? (also it talks about "other unbuffered queries", which is complete bull because there is no other query active, that delete command was the first and only query. also for some reason, this reproduce 100% reliably when connecting to a MySQL server in production, but it does not reproduce when connecting to a MariaDB server on dev (: )<|eost|><|eoss|><|endoftext|>
16
lolphp
nikic
gg5uv28
<|soss|><|sot|>consider using fetchAll() instead of fetchAll()<|eot|><|sost|>``` $ php -r '$db = new PDO('\''mysql:host=<censored>;port=<censored>;dbname=<censored>;charset=utf8mb4'\'','\''<censored>'\'','\''<censored>'\'',array ( PDO::ATTR_EMULATE_PREPARES=> false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ));$ret=$db->query('\''DELETE FROM global_error_logs WHERE id IN (2632431);'\'')->fetchAll();unset($db);var_export($ret);' ``` &nbsp; > PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in Command line code:5 > Stack trace: > #0 Command line code(5): PDOStatement->fetchAll() > #1 {main} > thrown in Command line code on line 5 (screenshot if reddit fucks up the the formatting: https://i.imgur.com/yG4oFhE.png ) it asks me to... consider using PDOStatement::fetchAll() instead of PDOStatement::fetchAll() ! genius, why didn't i think of that? (also it talks about "other unbuffered queries", which is complete bull because there is no other query active, that delete command was the first and only query. also for some reason, this reproduce 100% reliably when connecting to a MySQL server in production, but it does not reproduce when connecting to a MariaDB server on dev (: )<|eost|><|sor|>The problem here is that you are trying to fetch the result set of a query that does not have a result set. This results in an out of sync error, which is caused by an incompletely consumed unbuffered result set in the vast majority of cases, which is why PDO displays this error message. Of course, in this case the root cause was something else and the error message doesn't make a lot of sense. The good news is that this is fixed in the most recent PHP versions. Specifically, we have decided to allow fetching on queries without a result set, treating them effectively as if they returned an empty result set. This was already the case for emulated prepared statements. While using `exec()` for queries without result sets is certainly the recommended approach (and will also save you unnecessary roundtrips), this error condition was removed to facilitate working with abstractions that do not differentiate between queries with and without result sets. PS: I've been fixing bugs in mysqlnd and PDO MySQL the last few days... PHP 8.0.1 will have a lot of fixes.<|eor|><|eoss|><|endoftext|>
29
lolphp
colshrapnel
gg5aphc
<|soss|><|sot|>consider using fetchAll() instead of fetchAll()<|eot|><|sost|>``` $ php -r '$db = new PDO('\''mysql:host=<censored>;port=<censored>;dbname=<censored>;charset=utf8mb4'\'','\''<censored>'\'','\''<censored>'\'',array ( PDO::ATTR_EMULATE_PREPARES=> false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ));$ret=$db->query('\''DELETE FROM global_error_logs WHERE id IN (2632431);'\'')->fetchAll();unset($db);var_export($ret);' ``` &nbsp; > PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in Command line code:5 > Stack trace: > #0 Command line code(5): PDOStatement->fetchAll() > #1 {main} > thrown in Command line code on line 5 (screenshot if reddit fucks up the the formatting: https://i.imgur.com/yG4oFhE.png ) it asks me to... consider using PDOStatement::fetchAll() instead of PDOStatement::fetchAll() ! genius, why didn't i think of that? (also it talks about "other unbuffered queries", which is complete bull because there is no other query active, that delete command was the first and only query. also for some reason, this reproduce 100% reliably when connecting to a MySQL server in production, but it does not reproduce when connecting to a MariaDB server on dev (: )<|eost|><|sor|>I guess it's the result of your tricks with async queries. Because in my experience using fetchAll() on the queries that return no resultset would rather cause a generic General error. As of the suggestion to use fetchAll() - dunno if you are making a clown here, or genuinely don't understand the error message, but the phrase is related to the *previous* query, not one that caused the error.<|eor|><|eoss|><|endoftext|>
8
lolphp
colshrapnel
gg5h7ya
<|soss|><|sot|>consider using fetchAll() instead of fetchAll()<|eot|><|sost|>``` $ php -r '$db = new PDO('\''mysql:host=<censored>;port=<censored>;dbname=<censored>;charset=utf8mb4'\'','\''<censored>'\'','\''<censored>'\'',array ( PDO::ATTR_EMULATE_PREPARES=> false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ));$ret=$db->query('\''DELETE FROM global_error_logs WHERE id IN (2632431);'\'')->fetchAll();unset($db);var_export($ret);' ``` &nbsp; > PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in Command line code:5 > Stack trace: > #0 Command line code(5): PDOStatement->fetchAll() > #1 {main} > thrown in Command line code on line 5 (screenshot if reddit fucks up the the formatting: https://i.imgur.com/yG4oFhE.png ) it asks me to... consider using PDOStatement::fetchAll() instead of PDOStatement::fetchAll() ! genius, why didn't i think of that? (also it talks about "other unbuffered queries", which is complete bull because there is no other query active, that delete command was the first and only query. also for some reason, this reproduce 100% reliably when connecting to a MySQL server in production, but it does not reproduce when connecting to a MariaDB server on dev (: )<|eost|><|sor|>I guess it's the result of your tricks with async queries. Because in my experience using fetchAll() on the queries that return no resultset would rather cause a generic General error. As of the suggestion to use fetchAll() - dunno if you are making a clown here, or genuinely don't understand the error message, but the phrase is related to the *previous* query, not one that caused the error.<|eor|><|soopr|>> Because in my experience using fetchAll() on the queries that return no resultset would rather cause a generic General error. it's probably related that i used fetchAll() on a result-less query, the fix was ``` if (0 === stripos($query, 'DELETE FROM')) { $code .= '$ret=$db->exec(' . var_export($query, true) . ');'; } else { $code .= '$ret=$db->query(' . var_export($query, true) . ')->fetchAll();'; } ``` (which obviously isn't the whole story, the same distinction should be made for a shitton of queries, like a TRUNCATE TABLE and anything else which returns nothing), but it's good enough for now. > the phrase is related to the previous query, not one that caused the error. that's the thing, THERE IS NO PREVIOUS QUERY, it even happens when just doing a single (DELETE) query. but only when connecting to MySQL, not when connecting to MariaDB. weird shit, i know. > dunno if you are making a clown here, or genuinely don't understand the error message a bit of both<|eoopr|><|sor|>> THERE IS NO PREVIOUS QUERY There is. Like I said it's probably your tricks. Or may be there is a genuine error. Create a reproducible test case and fill the bug report. But your attempts to shit on the language are pathetic.<|eor|><|eoss|><|endoftext|>
6
lolphp
Takeoded
fxpdi5
<|sols|><|sot|>directly from 7.4.0RC6 to 7.4.3<|eot|><|sol|>https://i.redd.it/7c3verccgrr41.png<|eol|><|eols|><|endoftext|>
19
lolphp
elcapitanoooo
fmvp1es
<|sols|><|sot|>directly from 7.4.0RC6 to 7.4.3<|eot|><|sol|>https://i.redd.it/7c3verccgrr41.png<|eol|><|sor|>PHP has a history of this. One release shipped (cant remeber the version) with hundreds of broken tests. Top quality software..<|eor|><|eols|><|endoftext|>
18
lolphp
the_alias_of_andrea
fmvxx7w
<|sols|><|sot|>directly from 7.4.0RC6 to 7.4.3<|eot|><|sol|>https://i.redd.it/7c3verccgrr41.png<|eol|><|sor|>Eh, it seems like someone just forgot to update the homepage. The versions were not skipped, and there were several months between 7.4.0RC6 and 7.4.3: * https://www.php.net/ChangeLog-7.php#7.4.3 * https://news-web.php.net/php.announce * https://news-web.php.net/php.qa/68765<|eor|><|eols|><|endoftext|>
15
lolphp
sproingie
fmzse1w
<|sols|><|sot|>directly from 7.4.0RC6 to 7.4.3<|eot|><|sol|>https://i.redd.it/7c3verccgrr41.png<|eol|><|sor|>The maintenance of the PHP homepage is the real lolphp. As are the release notes. [This is how you do release notes](https://perldoc.perl.org/5.30.0/perldelta.html)<|eor|><|eols|><|endoftext|>
6
lolphp
DCoder1337
fmz82ij
<|sols|><|sot|>directly from 7.4.0RC6 to 7.4.3<|eot|><|sol|>https://i.redd.it/7c3verccgrr41.png<|eol|><|sor|>PHP has a history of this. One release shipped (cant remeber the version) with hundreds of broken tests. Top quality software..<|eor|><|sor|>You're probably thinking of this shitshow in 5.3.7: https://www.reddit.com/r/programming/comments/jsudd/_/c2evjct/?context=1<|eor|><|eols|><|endoftext|>
6
lolphp
Takeoded
bb6tb1
<|sols|><|sot|>base_convert's `string $number`<|eot|><|sol|>https://3v4l.org/nWaSc<|eol|><|eols|><|endoftext|>
17
lolphp
Takeoded
ekgmdmy
<|sols|><|sot|>base_convert's `string $number`<|eot|><|sol|>https://3v4l.org/nWaSc<|eol|><|soopr|>.. if someone wonders what \*should\* have happened: Fatal error: Uncaught TypeError: Argument 1 passed to base\_convert() must be of the type string, float given<|eoopr|><|eols|><|endoftext|>
8
lolphp
Takeoded
ekgsk8g
<|sols|><|sot|>base_convert's `string $number`<|eot|><|sol|>https://3v4l.org/nWaSc<|eol|><|soopr|>.. if someone wonders what \*should\* have happened: Fatal error: Uncaught TypeError: Argument 1 passed to base\_convert() must be of the type string, float given<|eoopr|><|sor|>Are you sure? I feel like the float can be casted to a string, even with strict typing. When passing in an array, yeah I would expect an exception.<|eor|><|soopr|>yes i'm sure: [https://3v4l.org/MgeqZ](https://3v4l.org/MgeqZ) a float is not supposed to be \*\*IMPLICITLY\*\* casted to string with strict\_types=1 - this is exactly the kind of stuff that strict\_types is supposed to prevent, but it's not working for base\_convert() AND EVEN IF IT DID WORK, this does something horrible but i g2g no time to explain rn<|eoopr|><|eols|><|endoftext|>
8
lolphp
SaltineAmerican_1970
ekgy3ag
<|sols|><|sot|>base_convert's `string $number`<|eot|><|sol|>https://3v4l.org/nWaSc<|eol|><|soopr|>.. if someone wonders what \*should\* have happened: Fatal error: Uncaught TypeError: Argument 1 passed to base\_convert() must be of the type string, float given<|eoopr|><|sor|>Are you sure? I feel like the float can be casted to a string, even with strict typing. When passing in an array, yeah I would expect an exception.<|eor|><|soopr|>yes i'm sure: [https://3v4l.org/MgeqZ](https://3v4l.org/MgeqZ) a float is not supposed to be \*\*IMPLICITLY\*\* casted to string with strict\_types=1 - this is exactly the kind of stuff that strict\_types is supposed to prevent, but it's not working for base\_convert() AND EVEN IF IT DID WORK, this does something horrible but i g2g no time to explain rn<|eoopr|><|sor|>Did you file a bug report?<|eor|><|eols|><|endoftext|>
5
lolphp
SquireCD
9h0jfj
<|sols|><|sot|>[/r/PHP X-POST] strlen() shenanigans<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/9gzskx/psa_strlen_does_not_get_the_length_of_the/<|eol|><|eols|><|endoftext|>
16
lolphp
r4ymonf
e68ao9p
<|sols|><|sot|>[/r/PHP X-POST] strlen() shenanigans<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/9gzskx/psa_strlen_does_not_get_the_length_of_the/<|eol|><|sor|>I don't think this is really lolphp material. It's essentially the same result you'd get with std::string::size() in C++ and (obviously) strlen in C, and there's a clear alternative that supports Unicode.<|eor|><|eols|><|endoftext|>
26
lolphp
shaql
e68sdi2
<|sols|><|sot|>[/r/PHP X-POST] strlen() shenanigans<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/9gzskx/psa_strlen_does_not_get_the_length_of_the/<|eol|><|sor|>I don't think this is really lolphp material. It's essentially the same result you'd get with std::string::size() in C++ and (obviously) strlen in C, and there's a clear alternative that supports Unicode.<|eor|><|sor|>I think the true lolphp is in the comments: https://www.reddit.com/r/PHP/comments/9gzskx/psa_strlen_does_not_get_the_length_of_the/e68dn8r/<|eor|><|eols|><|endoftext|>
25
lolphp
AyrA_ch
e68xp58
<|sols|><|sot|>[/r/PHP X-POST] strlen() shenanigans<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/9gzskx/psa_strlen_does_not_get_the_length_of_the/<|eol|><|sor|>I don't think this is really lolphp material. It's essentially the same result you'd get with std::string::size() in C++ and (obviously) strlen in C, and there's a clear alternative that supports Unicode.<|eor|><|sor|>The PHP docs even say that `strlen` counts bytes and a reference to the `mb_strlen` function is included in the help page. The problem here is that PHP sells you strings when in reality they are raw byte arrays which might confuse some people.<|eor|><|eols|><|endoftext|>
13
lolphp
AyrA_ch
e68zwo5
<|sols|><|sot|>[/r/PHP X-POST] strlen() shenanigans<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/9gzskx/psa_strlen_does_not_get_the_length_of_the/<|eol|><|sor|>I don't think this is really lolphp material. It's essentially the same result you'd get with std::string::size() in C++ and (obviously) strlen in C, and there's a clear alternative that supports Unicode.<|eor|><|sor|>The PHP docs even say that `strlen` counts bytes and a reference to the `mb_strlen` function is included in the help page. The problem here is that PHP sells you strings when in reality they are raw byte arrays which might confuse some people.<|eor|><|sor|>If anything the lolphp thing is it's a language targeting the web, where the vast majority of stuff is Unicode strings, without any Unicode string type.<|eor|><|sor|>You forget the age of PHP. It was created over 20 years ago when UTF-8 was only a few years old and pretty much unheard of.<|eor|><|eols|><|endoftext|>
13
lolphp
gsnedders
e68zmzs
<|sols|><|sot|>[/r/PHP X-POST] strlen() shenanigans<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/9gzskx/psa_strlen_does_not_get_the_length_of_the/<|eol|><|sor|>I don't think this is really lolphp material. It's essentially the same result you'd get with std::string::size() in C++ and (obviously) strlen in C, and there's a clear alternative that supports Unicode.<|eor|><|sor|>The PHP docs even say that `strlen` counts bytes and a reference to the `mb_strlen` function is included in the help page. The problem here is that PHP sells you strings when in reality they are raw byte arrays which might confuse some people.<|eor|><|sor|>If anything the lolphp thing is it's a language targeting the web, where the vast majority of stuff is Unicode strings, without any Unicode string type.<|eor|><|eols|><|endoftext|>
11
lolphp
minimim
e69ds26
<|sols|><|sot|>[/r/PHP X-POST] strlen() shenanigans<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/9gzskx/psa_strlen_does_not_get_the_length_of_the/<|eol|><|sor|>mb_strlen() doesn't count characters, it tries to count code-points.<|eor|><|eols|><|endoftext|>
5
lolphp
barubary
e6jitmo
<|sols|><|sot|>[/r/PHP X-POST] strlen() shenanigans<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/9gzskx/psa_strlen_does_not_get_the_length_of_the/<|eol|><|sor|>I don't think this is really lolphp material. It's essentially the same result you'd get with std::string::size() in C++ and (obviously) strlen in C, and there's a clear alternative that supports Unicode.<|eor|><|sor|>The PHP docs even say that `strlen` counts bytes and a reference to the `mb_strlen` function is included in the help page. The problem here is that PHP sells you strings when in reality they are raw byte arrays which might confuse some people.<|eor|><|sor|>If anything the lolphp thing is it's a language targeting the web, where the vast majority of stuff is Unicode strings, without any Unicode string type.<|eor|><|sor|>You forget the age of PHP. It was created over 20 years ago when UTF-8 was only a few years old and pretty much unheard of.<|eor|><|sor|>Cool story, but e.g. Perl gained fully integrated Unicode support back in 2002. At that time the PHP developers were still arguing over whether to enable the mbstring extension by default when building PHP (and e.g. `mb_strtolower` didn't even exist yet).<|eor|><|eols|><|endoftext|>
5
lolphp
pilif
4zof71
<|sols|><|sot|>version_compare(), when fed senseless data doesn't complain but treats 'p' differently<|eot|><|sol|>https://3v4l.org/v203M<|eol|><|eols|><|endoftext|>
18
lolphp
Almamu
d6xfbke
<|sols|><|sot|>version_compare(), when fed senseless data doesn't complain but treats 'p' differently<|eot|><|sol|>https://3v4l.org/v203M<|eol|><|sor|>This one is defined behavior and specified in the docs. http://php.net/manual/en/function.version-compare.php Look at the notes, # < pl = p, it's related to php versioning scheme AFAIK. Same happens with pl <|eor|><|eols|><|endoftext|>
12
lolphp
TheBuzzSaw
4oagr9
<|sols|><|sot|>"What do you plan to do about it?" -- "Nothing"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/4o7aa5/php_segfaults_on_30k_items_in_a_linked_list/d4aiev7<|eol|><|eols|><|endoftext|>
17
lolphp
Works_of_memercy
d4njr2y
<|sols|><|sot|>"What do you plan to do about it?" -- "Nothing"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/4o7aa5/php_segfaults_on_30k_items_in_a_linked_list/d4aiev7<|eol|><|sor|>Serious question (I am PHP dev): Guys, is it *that* hard to implement iteratable solution and just check the size of the list to be deleted? Or, knowing we are reaching the nesting limit, switch the solutions? Sure, it can create performance issues for the cases it would fail anyway.<|eor|><|sor|>No, it's not that hard and it is guaranteed to be more efficient (both in CPU time and memory-wise) than implicit recursion. Oh, and the problem is not in anything related to linked lists in particular but their generic object destructor -- turns out it can't handle deeply nested object hierarchies. I remember reading that one of PHP problems is that its core developers are not very good themselves, because, well, all good people that were around moved to greener pastures.<|eor|><|eols|><|endoftext|>
7
lolphp
nikic
d4upeo6
<|sols|><|sot|>"What do you plan to do about it?" -- "Nothing"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/4o7aa5/php_segfaults_on_30k_items_in_a_linked_list/d4aiev7<|eol|><|sor|>Serious question (I am PHP dev): Guys, is it *that* hard to implement iteratable solution and just check the size of the list to be deleted? Or, knowing we are reaching the nesting limit, switch the solutions? Sure, it can create performance issues for the cases it would fail anyway.<|eor|><|sor|>No, it's not that hard and it is guaranteed to be more efficient (both in CPU time and memory-wise) than implicit recursion. Oh, and the problem is not in anything related to linked lists in particular but their generic object destructor -- turns out it can't handle deeply nested object hierarchies. I remember reading that one of PHP problems is that its core developers are not very good themselves, because, well, all good people that were around moved to greener pastures.<|eor|><|sor|>> No, it's not that hard and it is guaranteed to be more efficient (both in CPU time and memory-wise) than implicit recursion. Guaranteed to be more efficient? Why are you so convinced of this? It is in principle easy to turn a recursive destruction into an iterative one if you don't care about performance, just keep sticking everything in a worklist. However, unless you happen to hit the degenerate case discussed here, managing this worklist is bound to have a non-trivial performance hit (and destruction is a critical code-path), if only because you end up visiting each element twice. An additional complication is that extension objects are non-homogeneous, so this has to be handled in a generic manner, where the outermost dtor performs the worklist based destruction, while all inner ones only insert to the list. This may lead to violations of assumptions about where precisely a value is destroyed (no longer at the point of invocation of the dtor) and about the order of destruction (as destructions would be reordered from DFS to BFS order -- I see no way to avoid that, again due to the necessity of being generic). Maybe I'm just too stupid for this, as you imply, but I really don't think this is as trivial as you make it out to be. (If I may say so, the discrepancy derives from the fact that you see this as an abstract problem, with an equally abstract simple solution, while I am considering specific issues of implementation and language semantics.)<|eor|><|eols|><|endoftext|>
6
lolphp
jozefNiepilsucki
d4meusv
<|sols|><|sot|>"What do you plan to do about it?" -- "Nothing"<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/4o7aa5/php_segfaults_on_30k_items_in_a_linked_list/d4aiev7<|eol|><|sor|>Serious question (I am PHP dev): Guys, is it *that* hard to implement iteratable solution and just check the size of the list to be deleted? Or, knowing we are reaching the nesting limit, switch the solutions? Sure, it can create performance issues for the cases it would fail anyway.<|eor|><|eols|><|endoftext|>
5
lolphp
kosinix
4lavbw
<|soss|><|sot|>SplPriorityQueue Does Not Behave Like a Queue<|eot|><|sost|>SplPriorityQueue is advertised as a prioritized queue. Ideally, as a queue, when adding items of the same priority, the items should retain the same order as how they were registered (FIFO). But No. In PHP the order is unexpected. Demo: https://3v4l.org/eNXSo Bug Wont Fix: https://bugs.php.net/bug.php?id=53710 Bug Wont Fix Reason: > There is no such guarantee. The only guarantee that you'll get from SplPriorityQueue is that you won't get an element out of order. Haha very funny. *shoots self*<|eost|><|eoss|><|endoftext|>
15
lolphp
dtfinch
d3m1e3t
<|soss|><|sot|>SplPriorityQueue Does Not Behave Like a Queue<|eot|><|sost|>SplPriorityQueue is advertised as a prioritized queue. Ideally, as a queue, when adding items of the same priority, the items should retain the same order as how they were registered (FIFO). But No. In PHP the order is unexpected. Demo: https://3v4l.org/eNXSo Bug Wont Fix: https://bugs.php.net/bug.php?id=53710 Bug Wont Fix Reason: > There is no such guarantee. The only guarantee that you'll get from SplPriorityQueue is that you won't get an element out of order. Haha very funny. *shoots self*<|eost|><|sor|>A priority queue is usually understood to be a [heap](https://en.wikipedia.org/wiki/Heap_%28data_structure%29) which makes no such FIFO guarantee. You could make it work by appending a counter to the priority (inverted since it's a max heap), same as they'd have to do to add the feature. Then I notice all of php's SPL heaps have a "[recoverFromCorruption()](http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php)" method. It hurts to imagine why such a thing is necessary. **Edit:** Maybe it's for re-ordering the heap if the priorities change, since you can supply your own comparison function and use objects/arrays as priorities, which also makes it easier to add that FIFO guarantee on your own.<|eor|><|eoss|><|endoftext|>
19
lolphp
Scaliwag
d3m93ie
<|soss|><|sot|>SplPriorityQueue Does Not Behave Like a Queue<|eot|><|sost|>SplPriorityQueue is advertised as a prioritized queue. Ideally, as a queue, when adding items of the same priority, the items should retain the same order as how they were registered (FIFO). But No. In PHP the order is unexpected. Demo: https://3v4l.org/eNXSo Bug Wont Fix: https://bugs.php.net/bug.php?id=53710 Bug Wont Fix Reason: > There is no such guarantee. The only guarantee that you'll get from SplPriorityQueue is that you won't get an element out of order. Haha very funny. *shoots self*<|eost|><|sor|>*Priority* queues are not FIFO. The caveat is dealing with equal priority elements ordering but when you use a priority queue you most likely don't care about intra priority ordering, after all if they all actually have the same priority it should not matter which one goes first, but I can see that being a problem in some cases.<|eor|><|eoss|><|endoftext|>
15
lolphp
the_alias_of_andrea
d3lryh3
<|soss|><|sot|>SplPriorityQueue Does Not Behave Like a Queue<|eot|><|sost|>SplPriorityQueue is advertised as a prioritized queue. Ideally, as a queue, when adding items of the same priority, the items should retain the same order as how they were registered (FIFO). But No. In PHP the order is unexpected. Demo: https://3v4l.org/eNXSo Bug Wont Fix: https://bugs.php.net/bug.php?id=53710 Bug Wont Fix Reason: > There is no such guarantee. The only guarantee that you'll get from SplPriorityQueue is that you won't get an element out of order. Haha very funny. *shoots self*<|eost|><|sor|>The Spl data structures are great pieces of work. There's not enough for them to be very useful, and the few data structures that it does have are implemented poorly.<|eor|><|eoss|><|endoftext|>
14
lolphp
the_alias_of_andrea
d3n0yyr
<|soss|><|sot|>SplPriorityQueue Does Not Behave Like a Queue<|eot|><|sost|>SplPriorityQueue is advertised as a prioritized queue. Ideally, as a queue, when adding items of the same priority, the items should retain the same order as how they were registered (FIFO). But No. In PHP the order is unexpected. Demo: https://3v4l.org/eNXSo Bug Wont Fix: https://bugs.php.net/bug.php?id=53710 Bug Wont Fix Reason: > There is no such guarantee. The only guarantee that you'll get from SplPriorityQueue is that you won't get an element out of order. Haha very funny. *shoots self*<|eost|><|sor|>A priority queue is usually understood to be a [heap](https://en.wikipedia.org/wiki/Heap_%28data_structure%29) which makes no such FIFO guarantee. You could make it work by appending a counter to the priority (inverted since it's a max heap), same as they'd have to do to add the feature. Then I notice all of php's SPL heaps have a "[recoverFromCorruption()](http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php)" method. It hurts to imagine why such a thing is necessary. **Edit:** Maybe it's for re-ordering the heap if the priorities change, since you can supply your own comparison function and use objects/arrays as priorities, which also makes it easier to add that FIFO guarantee on your own.<|eor|><|sor|>> Then I notice all of php's SPL heaps have a "recoverFromCorruption()" method. It hurts to imagine why such a thing is necessary. IIRC, if you write a broken comparator function then it can end up with a corrupted heap, and Spl will refuse to let you read/write from it. Unless you call `recoverFromCorruption`, which just unsets the flag that marks the heap as corrupted, allowing you to stick your fingers in your ears and ignore the problem (until PHP crashes, of course). I wish I was joking.<|eor|><|eoss|><|endoftext|>
9
lolphp
devseya
d3nylz4
<|soss|><|sot|>SplPriorityQueue Does Not Behave Like a Queue<|eot|><|sost|>SplPriorityQueue is advertised as a prioritized queue. Ideally, as a queue, when adding items of the same priority, the items should retain the same order as how they were registered (FIFO). But No. In PHP the order is unexpected. Demo: https://3v4l.org/eNXSo Bug Wont Fix: https://bugs.php.net/bug.php?id=53710 Bug Wont Fix Reason: > There is no such guarantee. The only guarantee that you'll get from SplPriorityQueue is that you won't get an element out of order. Haha very funny. *shoots self*<|eost|><|sor|>A priority queue is usually understood to be a [heap](https://en.wikipedia.org/wiki/Heap_%28data_structure%29) which makes no such FIFO guarantee. You could make it work by appending a counter to the priority (inverted since it's a max heap), same as they'd have to do to add the feature. Then I notice all of php's SPL heaps have a "[recoverFromCorruption()](http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php)" method. It hurts to imagine why such a thing is necessary. **Edit:** Maybe it's for re-ordering the heap if the priorities change, since you can supply your own comparison function and use objects/arrays as priorities, which also makes it easier to add that FIFO guarantee on your own.<|eor|><|sor|>> Then I notice all of php's SPL heaps have a "recoverFromCorruption()" method. It hurts to imagine why such a thing is necessary. IIRC, if you write a broken comparator function then it can end up with a corrupted heap, and Spl will refuse to let you read/write from it. Unless you call `recoverFromCorruption`, which just unsets the flag that marks the heap as corrupted, allowing you to stick your fingers in your ears and ignore the problem (until PHP crashes, of course). I wish I was joking.<|eor|><|sor|>The heap is marked as "corrupted" if the comparison function throws, after which any further interaction with the heap will also throw. recoverFromCorruption() allows you to say "I know what I'm doing" and continue using the heap.<|eor|><|sor|>Wonder why it is named "recover", instead of "allowCorruption" or something....<|eor|><|eoss|><|endoftext|>
5
lolphp
Takeoded
4inz48
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|eols|><|endoftext|>
17
lolphp
tdammers
d2zporp
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|sor|>I love this part: > Catchable fatal error: Argument 1 passed to a() must be an instance of int, int given<|eor|><|eols|><|endoftext|>
26
lolphp
DoctorWaluigiTime
d2zsrmt
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|sor|>I love this part: > Catchable fatal error: Argument 1 passed to a() must be an instance of int, int given<|eor|><|sor|>Welcome to how PHP implemented typehinting.<|eor|><|eols|><|endoftext|>
14
lolphp
tdammers
d2zpop2
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|sor|>Yes you should, it's [documented](http://php.net/func_get_args): > Note: This function returns a copy of the passed arguments only<|eor|><|soopr|>but why? is it just a implementation issue or is it a design decision? what's the logic behind not allowing references?<|eoopr|><|sor|>This is PHP. Logic does not exist.<|eor|><|eols|><|endoftext|>
13
lolphp
DoctorWaluigiTime
d2zsrdg
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|sor|>> call_user_func_array Let me stop you right there.<|eor|><|eols|><|endoftext|>
12
lolphp
Takeoded
d2zp40a
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|sor|>Yes you should, it's [documented](http://php.net/func_get_args): > Note: This function returns a copy of the passed arguments only<|eor|><|soopr|>but why? is it just a implementation issue or is it a design decision? what's the logic behind not allowing references?<|eoopr|><|eols|><|endoftext|>
9
lolphp
tdammers
d2zu8ek
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|sor|>I love this part: > Catchable fatal error: Argument 1 passed to a() must be an instance of int, int given<|eor|><|sor|>Welcome to how PHP implemented typehinting.<|eor|><|sor|>Or "types" in general. Really though, I suspect this is actually just an implementation detail of HHVM leaking out, seeing how the other runtimes report different types.<|eor|><|eols|><|endoftext|>
7
lolphp
gearvOsh
d30mxk9
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|sor|>Can someone explain why this doesn't work?<|eor|><|sor|>Because `func_get_args()` passes by value.<|eor|><|eols|><|endoftext|>
6
lolphp
cite-reader
d30quun
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|sor|>Can someone explain why this doesn't work?<|eor|><|sor|>Because `func_get_args()` passes by value.<|eor|><|sor|>And also references aren't actually values. "Reference-ness" is a magical property of a variable which doesn't interact in a sensible way with the rest of the language.<|eor|><|eols|><|endoftext|>
6
lolphp
nikic
d319o1w
<|sols|><|sot|>i should have expected php to be incapable of keeping references, right?<|eot|><|sol|>https://3v4l.org/4IhEq<|eol|><|sor|>Yes you should, it's [documented](http://php.net/func_get_args): > Note: This function returns a copy of the passed arguments only<|eor|><|soopr|>but why? is it just a implementation issue or is it a design decision? what's the logic behind not allowing references?<|eoopr|><|sor|>It's not an implementation issue.<|eor|><|eols|><|endoftext|>
5
lolphp
terrkerr
4avbba
<|soss|><|sot|>const Attributes and array addition<|eot|><|sost|>So for reasons I wanted a bunch of classes that specified all valid attributes they could have, and also specify all attributes that they *must* have to be considered valid. Since the latter list is necessarily a subset of the former I wrote out something like this. class Foo { const THIS = [ 1, 2, ]; const THAT = FOO::THIS + [ 10, 20, 30, 40, ]; } I didn't expect this to work, but I thought: Hey, maybe PHP will let this work or, worst-case scenario it yells at me and I stop that shit. I ran it (PHP 7.0.4) and no FATALs, no WARNINGs, no nothing. It worked, right? [lolphp](https://3v4l.org/KtQpZ)<|eost|><|eoss|><|endoftext|>
16
lolphp
maweki
d13w9tm
<|soss|><|sot|>const Attributes and array addition<|eot|><|sost|>So for reasons I wanted a bunch of classes that specified all valid attributes they could have, and also specify all attributes that they *must* have to be considered valid. Since the latter list is necessarily a subset of the former I wrote out something like this. class Foo { const THIS = [ 1, 2, ]; const THAT = FOO::THIS + [ 10, 20, 30, 40, ]; } I didn't expect this to work, but I thought: Hey, maybe PHP will let this work or, worst-case scenario it yells at me and I stop that shit. I ran it (PHP 7.0.4) and no FATALs, no WARNINGs, no nothing. It worked, right? [lolphp](https://3v4l.org/KtQpZ)<|eost|><|sor|>"The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored." http://php.net/manual/en/language.operators.array.php And since *obviously* 1 and 10 / 2 and 20 have the same indices, this could somehow qualify as expected behavior. Right? RIGHT? And therefore I give you this: https://3v4l.org/p5TCt Array_merge is correct for numerically indexed arrays.<|eor|><|eoss|><|endoftext|>
23
lolphp
phpguy2
d14d18f
<|soss|><|sot|>const Attributes and array addition<|eot|><|sost|>So for reasons I wanted a bunch of classes that specified all valid attributes they could have, and also specify all attributes that they *must* have to be considered valid. Since the latter list is necessarily a subset of the former I wrote out something like this. class Foo { const THIS = [ 1, 2, ]; const THAT = FOO::THIS + [ 10, 20, 30, 40, ]; } I didn't expect this to work, but I thought: Hey, maybe PHP will let this work or, worst-case scenario it yells at me and I stop that shit. I ran it (PHP 7.0.4) and no FATALs, no WARNINGs, no nothing. It worked, right? [lolphp](https://3v4l.org/KtQpZ)<|eost|><|sor|>"The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored." http://php.net/manual/en/language.operators.array.php And since *obviously* 1 and 10 / 2 and 20 have the same indices, this could somehow qualify as expected behavior. Right? RIGHT? And therefore I give you this: https://3v4l.org/p5TCt Array_merge is correct for numerically indexed arrays.<|eor|><|sor|>>And since obviously 1 and 10 / 2 and 20 have the same indices, this could somehow qualify as expected behavior. Right? RIGHT? It says that the right array will be "appended" to the left array, in the first sentence and goes on to explain that it does not append them, but actually merge the two arrays. But the function that actually do the appending is called array_merge!?<|eor|><|eoss|><|endoftext|>
10
lolphp
serendependy
d14p1ff
<|soss|><|sot|>const Attributes and array addition<|eot|><|sost|>So for reasons I wanted a bunch of classes that specified all valid attributes they could have, and also specify all attributes that they *must* have to be considered valid. Since the latter list is necessarily a subset of the former I wrote out something like this. class Foo { const THIS = [ 1, 2, ]; const THAT = FOO::THIS + [ 10, 20, 30, 40, ]; } I didn't expect this to work, but I thought: Hey, maybe PHP will let this work or, worst-case scenario it yells at me and I stop that shit. I ran it (PHP 7.0.4) and no FATALs, no WARNINGs, no nothing. It worked, right? [lolphp](https://3v4l.org/KtQpZ)<|eost|><|sor|>Performing a union of the two arrays by keys isn't really all that unreasonable here.<|eor|><|sor|>It's pretty bizarre for it to be named +<|eor|><|eoss|><|endoftext|>
5
lolphp
maweki
d14fimv
<|soss|><|sot|>const Attributes and array addition<|eot|><|sost|>So for reasons I wanted a bunch of classes that specified all valid attributes they could have, and also specify all attributes that they *must* have to be considered valid. Since the latter list is necessarily a subset of the former I wrote out something like this. class Foo { const THIS = [ 1, 2, ]; const THAT = FOO::THIS + [ 10, 20, 30, 40, ]; } I didn't expect this to work, but I thought: Hey, maybe PHP will let this work or, worst-case scenario it yells at me and I stop that shit. I ran it (PHP 7.0.4) and no FATALs, no WARNINGs, no nothing. It worked, right? [lolphp](https://3v4l.org/KtQpZ)<|eost|><|sor|>"The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored." http://php.net/manual/en/language.operators.array.php And since *obviously* 1 and 10 / 2 and 20 have the same indices, this could somehow qualify as expected behavior. Right? RIGHT? And therefore I give you this: https://3v4l.org/p5TCt Array_merge is correct for numerically indexed arrays.<|eor|><|sor|>>And since obviously 1 and 10 / 2 and 20 have the same indices, this could somehow qualify as expected behavior. Right? RIGHT? It says that the right array will be "appended" to the left array, in the first sentence and goes on to explain that it does not append them, but actually merge the two arrays. But the function that actually do the appending is called array_merge!?<|eor|><|sor|>I can somehow see how + might not be append but the union-operator but why the f is the dot, which is used for string CONCATENATION, not a nice operator to use for that? > But the function that actually do the appending is called array_merge!? Yeah, WTF?<|eor|><|eoss|><|endoftext|>
5
lolphp
Farkeman
42kupy
<|sols|><|sot|>Php proposes code of conduct<|eot|><|sol|>https://wiki.php.net/rfc/adopt-code-of-conduct<|eol|><|eols|><|endoftext|>
17
lolphp
jdickey
czbcdxm
<|sols|><|sot|>Php proposes code of conduct<|eot|><|sol|>https://wiki.php.net/rfc/adopt-code-of-conduct<|eol|><|sor|>Our previous discussion on the topic: https://www.reddit.com/r/lolphp/comments/3zikur/grap_your_popcorns_for_a_bit_of_phpdrama_and/<|eor|><|sor|>There's not enough popcorn in the history of the planet; after spending half my adult life in societies which celebrate people with one or more traits that I share being on the bottom of the pile, I can appreciate the idea behind CoC, and even the folks behind contributor-covenant.org. Because two facts tend to get lost on people in these discussions: first, external differences which are not individuals' personal responsibility *does* impact their ability to contribute to their full "meritocratic" potential, and second, we are all, or nearly all here, *human* and deserve to be treated (and to treat others) as such. Living in a self-glorifyingly racist culture, I have taken to writing "HUMAN" in each of the interminable Government and Government-linked-company forms that have, as typically the very first space on the form, "RACE".<|eor|><|eols|><|endoftext|>
15
lolphp
qwerty6868
czblv4b
<|sols|><|sot|>Php proposes code of conduct<|eot|><|sol|>https://wiki.php.net/rfc/adopt-code-of-conduct<|eol|><|sor|>PHP: The gift that keeps on giving. What a cesspool of incompetence.<|eor|><|eols|><|endoftext|>
13
lolphp
Farkeman
czb3yjv
<|sols|><|sot|>Php proposes code of conduct<|eot|><|sol|>https://wiki.php.net/rfc/adopt-code-of-conduct<|eol|><|soopr|>One of the points is: "Thoughtless use of pronouns" What a world we live in!<|eoopr|><|eols|><|endoftext|>
11
lolphp
maweki
czbe1k1
<|sols|><|sot|>Php proposes code of conduct<|eot|><|sol|>https://wiki.php.net/rfc/adopt-code-of-conduct<|eol|><|sor|>Our previous discussion on the topic: https://www.reddit.com/r/lolphp/comments/3zikur/grap_your_popcorns_for_a_bit_of_phpdrama_and/<|eor|><|sor|>There's not enough popcorn in the history of the planet; after spending half my adult life in societies which celebrate people with one or more traits that I share being on the bottom of the pile, I can appreciate the idea behind CoC, and even the folks behind contributor-covenant.org. Because two facts tend to get lost on people in these discussions: first, external differences which are not individuals' personal responsibility *does* impact their ability to contribute to their full "meritocratic" potential, and second, we are all, or nearly all here, *human* and deserve to be treated (and to treat others) as such. Living in a self-glorifyingly racist culture, I have taken to writing "HUMAN" in each of the interminable Government and Government-linked-company forms that have, as typically the very first space on the form, "RACE".<|eor|><|sor|>Well, to be fair, I don't think that a CoC is strictly necessary for any community, but considering on what level (and with what kind of language) the discussion about the CoC is held, it seems not a bad idea for this particular one.<|eor|><|sor|>That's a bit circular tho. Also, no CoC might be better than a bad CoC.<|eor|><|sor|>Well, lot of the first reactions where along the lines of "those Nazis are going to reprimand us for our language". That's not the basis for a discussion though, right? If the reaction would have been "I don't think it is necessary, we have all been civil here" and if that then also were true...<|eor|><|eols|><|endoftext|>
11
lolphp
maweki
czb5k1k
<|sols|><|sot|>Php proposes code of conduct<|eot|><|sol|>https://wiki.php.net/rfc/adopt-code-of-conduct<|eol|><|sor|>Our previous discussion on the topic: https://www.reddit.com/r/lolphp/comments/3zikur/grap_your_popcorns_for_a_bit_of_phpdrama_and/<|eor|><|eols|><|endoftext|>
9
lolphp
fgous
czbi2hj
<|sols|><|sot|>Php proposes code of conduct<|eot|><|sol|>https://wiki.php.net/rfc/adopt-code-of-conduct<|eol|><|sor|>Funny thing is [no one can point to an instance of abuse](https://www.reddit.com/r/PHP/comments/41vuja/rfc_reproposed_adopt_code_of_conduct/cz6pecs) in the internals in the past.....<|eor|><|eols|><|endoftext|>
8
lolphp
maweki
czbdgcu
<|sols|><|sot|>Php proposes code of conduct<|eot|><|sol|>https://wiki.php.net/rfc/adopt-code-of-conduct<|eol|><|sor|>Our previous discussion on the topic: https://www.reddit.com/r/lolphp/comments/3zikur/grap_your_popcorns_for_a_bit_of_phpdrama_and/<|eor|><|sor|>There's not enough popcorn in the history of the planet; after spending half my adult life in societies which celebrate people with one or more traits that I share being on the bottom of the pile, I can appreciate the idea behind CoC, and even the folks behind contributor-covenant.org. Because two facts tend to get lost on people in these discussions: first, external differences which are not individuals' personal responsibility *does* impact their ability to contribute to their full "meritocratic" potential, and second, we are all, or nearly all here, *human* and deserve to be treated (and to treat others) as such. Living in a self-glorifyingly racist culture, I have taken to writing "HUMAN" in each of the interminable Government and Government-linked-company forms that have, as typically the very first space on the form, "RACE".<|eor|><|sor|>Well, to be fair, I don't think that a CoC is strictly necessary for any community, but considering on what level (and with what kind of language) the discussion about the CoC is held, it seems not a bad idea for this particular one.<|eor|><|eols|><|endoftext|>
8