subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
vytah
ckdumjr
<|sols|><|sot|>array_diff: Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same.<|eot|><|sol|>http://php.net/manual/en/function.array-diff.php<|eol|><|sor|>Predicates are hard. String concatenation is easy. /language<|eor|><|sor|> Predicates are hard, concatenation easy. A complete language. <|eor|><|eols|><|endoftext|>
10
lolphp
Various_Pickles
ckdugus
<|sols|><|sot|>array_diff: Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same.<|eot|><|sol|>http://php.net/manual/en/function.array-diff.php<|eol|><|sor|>Predicates are hard. String concatenation is easy. /language<|eor|><|eols|><|endoftext|>
7
lolphp
TheDistantSea
2e632o
<|sols|><|sot|>What could go wrong with simply cloning this object?<|eot|><|sol|>http://stackoverflow.com/q/25420812/50079<|eol|><|eols|><|endoftext|>
37
lolphp
TheDistantSea
cjwfm9z
<|sols|><|sot|>What could go wrong with simply cloning this object?<|eot|><|sol|>http://stackoverflow.com/q/25420812/50079<|eol|><|sor|>> If you `var_dump($this->data)` before and after `assignReferences` in the constructor you will see that assigning those references causes the contents of `$this->data` to *become references themselves*. What? How? Why?!?<|eor|><|soopr|>Basically it's a ZVAL-related clusterfuck. http://webandphp.com/how-php-manages-variables See section "references", and mentions of "is_ref" in particular. When you ref-assign a ZVAL with refcount = 1 and is_ref = 0 PHP increases the refcount and makes is_ref = 1. This happens to the values inside $this->data in the example, so when $this->data is cloned you end up cloning references even though you didn't put references in there to begin with.<|eoopr|><|eols|><|endoftext|>
12
lolphp
callcifer
cjwejiz
<|sols|><|sot|>What could go wrong with simply cloning this object?<|eot|><|sol|>http://stackoverflow.com/q/25420812/50079<|eol|><|sor|>> If you `var_dump($this->data)` before and after `assignReferences` in the constructor you will see that assigning those references causes the contents of `$this->data` to *become references themselves*. What? How? Why?!?<|eor|><|eols|><|endoftext|>
11
lolphp
Banane9
cjxcv07
<|sols|><|sot|>What could go wrong with simply cloning this object?<|eot|><|sol|>http://stackoverflow.com/q/25420812/50079<|eol|><|sor|>For whatever reason, this seems perfectly expected to me. <|eor|><|sor|>You just get used to PHP being a clusterfuck.<|eor|><|eols|><|endoftext|>
5
lolphp
anlutro
2bl1j9
<|sols|><|sot|>Finally a good practical use for string incrementing!<|eot|><|sol|>http://3v4l.org/VXLuc<|eol|><|eols|><|endoftext|>
37
lolphp
BadFurDay
cj6cke8
<|sols|><|sot|>Finally a good practical use for string incrementing!<|eot|><|sol|>http://3v4l.org/VXLuc<|eol|><|sor|>I hope people start using this genius idea enough that there would be a major backlash if php ever decides to fix strings.<|eor|><|eols|><|endoftext|>
21
lolphp
ajmarks
cj6n6jw
<|sols|><|sot|>Finally a good practical use for string incrementing!<|eot|><|sol|>http://3v4l.org/VXLuc<|eol|><|sor|>Should h2 to h3 be --$heading?<|eor|><|sor|>2+1=3<|eor|><|sor|>h3 < h2<|eor|><|eols|><|endoftext|>
15
lolphp
Trig90
cj6cz8q
<|sols|><|sot|>Finally a good practical use for string incrementing!<|eot|><|sol|>http://3v4l.org/VXLuc<|eol|><|sor|>I hope people start using this genius idea enough that there would be a major backlash if php ever decides to fix strings.<|eor|><|sor|>relevant http://xkcd.com/1172/<|eor|><|eols|><|endoftext|>
13
lolphp
ajmarks
cj6p0qt
<|sols|><|sot|>Finally a good practical use for string incrementing!<|eot|><|sol|>http://3v4l.org/VXLuc<|eol|><|sor|>Should h2 to h3 be --$heading?<|eor|><|sor|>2+1=3<|eor|><|sor|>h3 < h2<|eor|><|sor|>Its not like this is built into PHP.<|eor|><|sor|>thatsthejoke.gif<|eor|><|eols|><|endoftext|>
13
lolphp
ajmarks
cj6g08d
<|sols|><|sot|>Finally a good practical use for string incrementing!<|eot|><|sol|>http://3v4l.org/VXLuc<|eol|><|sor|>Should h2 to h3 be --$heading?<|eor|><|eols|><|endoftext|>
12
lolphp
image_linker_bot
cj6p1dh
<|sols|><|sot|>Finally a good practical use for string incrementing!<|eot|><|sol|>http://3v4l.org/VXLuc<|eol|><|sor|>Should h2 to h3 be --$heading?<|eor|><|sor|>2+1=3<|eor|><|sor|>h3 < h2<|eor|><|sor|>Its not like this is built into PHP.<|eor|><|sor|>thatsthejoke.gif<|eor|><|sor|>[thatsthejoke.gif](http://i.imgur.com/NTgQZB4.jpg) --- ^(*Feedback welcome at /r/image_linker_bot*) <|eor|><|eols|><|endoftext|>
11
lolphp
xkcd_transcriber
cj6czgj
<|sols|><|sot|>Finally a good practical use for string incrementing!<|eot|><|sol|>http://3v4l.org/VXLuc<|eol|><|sor|>I hope people start using this genius idea enough that there would be a major backlash if php ever decides to fix strings.<|eor|><|sor|>relevant http://xkcd.com/1172/<|eor|><|sor|>[Image](http://imgs.xkcd.com/comics/workflow.png) **Title:** Workflow **Title-text:** There are probably children out there holding down spacebar to stay warm in the winter! YOUR UPDATE MURDERS CHILDREN. [Comic Explanation](http://www.explainxkcd.com/wiki/index.php?title=1172#Explanation) **Stats:** This comic has been referenced 121 times, representing 0.4365% of referenced xkcds. --- ^[xkcd.com](http://www.xkcd.com) ^| ^[xkcdsub](http://www.reddit.com/r/xkcdcomic/)/[kerfuffle](http://www.reddit.com/r/self/comments/1xdwba/the_history_of_the_rxkcd_kerfuffle/) ^| ^[Problems/Bugs?](http://www.reddit.com/r/xkcd_transcriber/) ^| ^[Statistics](http://xkcdref.info/statistics/) ^| ^[StopReplying](http://reddit.com/message/compose/?to=xkcd_transcriber&subject=ignore%20me&message=ignore%20me) ^| ^[Delete](http://reddit.com/message/compose/?to=xkcd_transcriber&subject=delete&message=delete%20t1_cj6czgj)<|eor|><|eols|><|endoftext|>
5
lolphp
midir
y7dun
<|soss|><|sot|>The PHP way: Variables are case-sensitive but function names are not. Class names aren't either, unless you autoload them on a case-sensitive filesystem, then case matters again.<|eot|><|sost|>Keywords are case-insensitive too, apparently. This works: <?PHP label: PRINT "Hello World!"; GOTO label ?> Edit: Oh, but label names are case-sensitive.<|eost|><|eoss|><|endoftext|>
38
lolphp
Persism
tw1426
<|sols|><|sot|>15-Year-Old Bug in PEAR PHP Repository Could've Enabled Supply Chain Attacks<|eot|><|sol|>https://thehackernews.com/2022/04/15-year-old-bug-in-pear-php-repository.html?m=1<|eol|><|eols|><|endoftext|>
38
lolphp
morphotomy
i3ck7vf
<|sols|><|sot|>15-Year-Old Bug in PEAR PHP Repository Could've Enabled Supply Chain Attacks<|eot|><|sol|>https://thehackernews.com/2022/04/15-year-old-bug-in-pear-php-repository.html?m=1<|eol|><|sor|>... if anyone actually used PEAR.<|eor|><|eols|><|endoftext|>
24
lolphp
barubary
i3gpzks
<|sols|><|sot|>15-Year-Old Bug in PEAR PHP Repository Could've Enabled Supply Chain Attacks<|eot|><|sol|>https://thehackernews.com/2022/04/15-year-old-bug-in-pear-php-repository.html?m=1<|eol|><|sor|>The password reset bug is great. The original implementation of `passwordmanage.php` from 15 years ago generates reset tokens like this: $salt = md5(mt_rand(4,13) . $user . time() . $pass1); (Yes, it calls the reset token "salt".) Of these parameters, `$user` and `$pass1` are known to (or rather chosen by) the attacker (they're the username being attacked and the new password, respectively, straight from the POST form). Since `time()` is a unix timestamp with one second granularity, it is extremely guessable. That leaves `mt_rand(4,13)` as the sole source of randomness. The parameters to `mt_rand` are simply the bounds of the interval in which to generate random integers. That is, the call `mt_rand(4,13)` can only return 10 possible values: 4, 5, 6, 7, 8, 9, 10, 11, 12, or 13. If I'm reading this code right, it should take an attacker only 10 tries in the worst case to guess the right reset token. This file remained essentially unchanged for 15 years, until about eight months ago, when it was changed as follows: $random_bytes = openssl_random_pseudo_bytes(16, $strong); // error checks omitted $salt = md5($rand_bytes); ... which looks much better, but is even worse: This code tries to compute the MD5 hash of an uninitialized variable, which is always `d41d8cd98f00b204e9800998ecf8427e`. Fortunately someone noticed that `$random_bytes` is not the same variable as `$rand_bytes`, and it was changed to `md5($random_bytes)` on the same day. --- Bonus lolphp: The actual passwords are stored as `md5($pass1)`, i.e. straight unsalted MD5. --- Bonus bonus lolphp: The function that contains this code has three parameters: function resetPassword($user, $pass1, $pass2) These are documented as follows: /** * Mark a user for password resetting * * @param string $user * @param string $pass1 * @param string $pass2 * @return array */ ... i.e. not at all. In practice, `$user` is the handle or user ID of the account, `$pass1` is the new password entered by the user (whose MD5 hash is stored in the database), and `$pass2` is unused. In fact, it's not clear what it was intended for because `$pass2` always has been unused since version 1 of the code. The only caller of this function very carefully passes in `$_POST['password']` as `$pass1` (the "new password" field) and `$_POST['password2']` as `$pass2` (the "confirm new password" field). However, it also makes sure that the two form fields have the same value before calling `resetPassword()`, so there really is no point.<|eor|><|eols|><|endoftext|>
14
lolphp
Persism
i3hhi9l
<|sols|><|sot|>15-Year-Old Bug in PEAR PHP Repository Could've Enabled Supply Chain Attacks<|eot|><|sol|>https://thehackernews.com/2022/04/15-year-old-bug-in-pear-php-repository.html?m=1<|eol|><|sor|>The password reset bug is great. The original implementation of `passwordmanage.php` from 15 years ago generates reset tokens like this: $salt = md5(mt_rand(4,13) . $user . time() . $pass1); (Yes, it calls the reset token "salt".) Of these parameters, `$user` and `$pass1` are known to (or rather chosen by) the attacker (they're the username being attacked and the new password, respectively, straight from the POST form). Since `time()` is a unix timestamp with one second granularity, it is extremely guessable. That leaves `mt_rand(4,13)` as the sole source of randomness. The parameters to `mt_rand` are simply the bounds of the interval in which to generate random integers. That is, the call `mt_rand(4,13)` can only return 10 possible values: 4, 5, 6, 7, 8, 9, 10, 11, 12, or 13. If I'm reading this code right, it should take an attacker only 10 tries in the worst case to guess the right reset token. This file remained essentially unchanged for 15 years, until about eight months ago, when it was changed as follows: $random_bytes = openssl_random_pseudo_bytes(16, $strong); // error checks omitted $salt = md5($rand_bytes); ... which looks much better, but is even worse: This code tries to compute the MD5 hash of an uninitialized variable, which is always `d41d8cd98f00b204e9800998ecf8427e`. Fortunately someone noticed that `$random_bytes` is not the same variable as `$rand_bytes`, and it was changed to `md5($random_bytes)` on the same day. --- Bonus lolphp: The actual passwords are stored as `md5($pass1)`, i.e. straight unsalted MD5. --- Bonus bonus lolphp: The function that contains this code has three parameters: function resetPassword($user, $pass1, $pass2) These are documented as follows: /** * Mark a user for password resetting * * @param string $user * @param string $pass1 * @param string $pass2 * @return array */ ... i.e. not at all. In practice, `$user` is the handle or user ID of the account, `$pass1` is the new password entered by the user (whose MD5 hash is stored in the database), and `$pass2` is unused. In fact, it's not clear what it was intended for because `$pass2` always has been unused since version 1 of the code. The only caller of this function very carefully passes in `$_POST['password']` as `$pass1` (the "new password" field) and `$_POST['password2']` as `$pass2` (the "confirm new password" field). However, it also makes sure that the two form fields have the same value before calling `resetPassword()`, so there really is no point.<|eor|><|soopr|>> someone noticed that $random_bytes is not the same variable as $rand_bytes ROFL<|eoopr|><|eols|><|endoftext|>
7
lolphp
morphotomy
i3hhz0g
<|sols|><|sot|>15-Year-Old Bug in PEAR PHP Repository Could've Enabled Supply Chain Attacks<|eot|><|sol|>https://thehackernews.com/2022/04/15-year-old-bug-in-pear-php-repository.html?m=1<|eol|><|sor|>The password reset bug is great. The original implementation of `passwordmanage.php` from 15 years ago generates reset tokens like this: $salt = md5(mt_rand(4,13) . $user . time() . $pass1); (Yes, it calls the reset token "salt".) Of these parameters, `$user` and `$pass1` are known to (or rather chosen by) the attacker (they're the username being attacked and the new password, respectively, straight from the POST form). Since `time()` is a unix timestamp with one second granularity, it is extremely guessable. That leaves `mt_rand(4,13)` as the sole source of randomness. The parameters to `mt_rand` are simply the bounds of the interval in which to generate random integers. That is, the call `mt_rand(4,13)` can only return 10 possible values: 4, 5, 6, 7, 8, 9, 10, 11, 12, or 13. If I'm reading this code right, it should take an attacker only 10 tries in the worst case to guess the right reset token. This file remained essentially unchanged for 15 years, until about eight months ago, when it was changed as follows: $random_bytes = openssl_random_pseudo_bytes(16, $strong); // error checks omitted $salt = md5($rand_bytes); ... which looks much better, but is even worse: This code tries to compute the MD5 hash of an uninitialized variable, which is always `d41d8cd98f00b204e9800998ecf8427e`. Fortunately someone noticed that `$random_bytes` is not the same variable as `$rand_bytes`, and it was changed to `md5($random_bytes)` on the same day. --- Bonus lolphp: The actual passwords are stored as `md5($pass1)`, i.e. straight unsalted MD5. --- Bonus bonus lolphp: The function that contains this code has three parameters: function resetPassword($user, $pass1, $pass2) These are documented as follows: /** * Mark a user for password resetting * * @param string $user * @param string $pass1 * @param string $pass2 * @return array */ ... i.e. not at all. In practice, `$user` is the handle or user ID of the account, `$pass1` is the new password entered by the user (whose MD5 hash is stored in the database), and `$pass2` is unused. In fact, it's not clear what it was intended for because `$pass2` always has been unused since version 1 of the code. The only caller of this function very carefully passes in `$_POST['password']` as `$pass1` (the "new password" field) and `$_POST['password2']` as `$pass2` (the "confirm new password" field). However, it also makes sure that the two form fields have the same value before calling `resetPassword()`, so there really is no point.<|eor|><|soopr|>> someone noticed that $random_bytes is not the same variable as $rand_bytes ROFL<|eoopr|><|sor|>This is why you make your shit die on `notice`.<|eor|><|eols|><|endoftext|>
6
lolphp
kalcora
sml1sm
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|eoss|><|endoftext|>
39
lolphp
chucker23n
hvxtetc
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>Thats not a lol. Thats failure to read documentation. If you want a lol, read up on the SPL structures that tell you that `top()` peeks at the node from the end and `bottom()` peeks at the node from the beginning.<|eor|><|sor|>>Thats not a lol. Thats failure to read documentation. Sometimes, things work as documented but are still bad. Why would you ever want `and` to have lower precedence than `=`? The only explanation I can see is legacy compatibility.<|eor|><|eoss|><|endoftext|>
21
lolphp
blbil
hvyiybq
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>[deleted]<|eor|><|sor|>The title of the post is Operator Precedence...........<|eor|><|sor|>The OP thinks it's a LOL. Which means they need to learn what does Operator precedence actually mean, not just use it as a post title.<|eor|><|sor|>It seems to me they understand it decently enough. A lolphp is not only "I found some undocumented behaviour", it is also "holy shit, THIS is how php actually works wtf".<|eor|><|eoss|><|endoftext|>
12
lolphp
sproingie
hvyj61g
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>More like lolperl, since the operators came from there, precedence and all. Thing is, I still don't get how the second one evaluates to true, regardless of precedence. If it were `$b = (true and false)`, then it should assign false, and evaluate to false. But it's `($b = true) and false`, which should assign true, then evaluate the rest of the expression to false. Even perl is making me question my ~~sanity~~ memory: perl -E '$b = false and say "wat"' wat<|eor|><|eoss|><|endoftext|>
11
lolphp
colshrapnel
hvypmt4
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>More like lolperl, since the operators came from there, precedence and all. Thing is, I still don't get how the second one evaluates to true, regardless of precedence. If it were `$b = (true and false)`, then it should assign false, and evaluate to false. But it's `($b = true) and false`, which should assign true, then evaluate the rest of the expression to false. Even perl is making me question my ~~sanity~~ memory: perl -E '$b = false and say "wat"' wat<|eor|><|sor|>> then evaluate the rest of the expression to false Actually it does. But there is simply no variable to receive the result. It's sort of explained [in my article](https://phpdelusions.net/articles/or_die), though for OR: true AND false is a statement on its own, it evaluates all right, though its result is recorded nowhere. ($b = true) and false is actually the same, `exp1 AND exp2` and evaluates to `false`. Just the result goes void. but if you record it, it gets you false $c = ($b = true and false); var_dump($b, $c);<|eor|><|eoss|><|endoftext|>
9
lolphp
colshrapnel
hvxgf7t
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>Use parenthesis.<|eor|><|sor|>It is not a help post it's a lol post. The OP thinks this behavior is somewhat ridiculous and expects it to be fixed in some future version.<|eor|><|eoss|><|endoftext|>
9
lolphp
blbil
hvxqxu2
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>[deleted]<|eor|><|sor|>The title of the post is Operator Precedence...........<|eor|><|eoss|><|endoftext|>
8
lolphp
barubary
hvzolsd
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>More like lolperl, since the operators came from there, precedence and all. Thing is, I still don't get how the second one evaluates to true, regardless of precedence. If it were `$b = (true and false)`, then it should assign false, and evaluate to false. But it's `($b = true) and false`, which should assign true, then evaluate the rest of the expression to false. Even perl is making me question my ~~sanity~~ memory: perl -E '$b = false and say "wat"' wat<|eor|><|sor|>> Even perl is making me question my sanity: OK, let's try that with warnings enabled. :-) $ perl -wE '$b = false and say "wat"' Unquoted string "false" may clash with future reserved word at -e line 1. Found = in conditional, should be == at -e line 1. wat And now in strict mode: $ perl -Mstrict -wE '$b = false and say "wat"' Found = in conditional, should be == at -e line 1. Bareword "false" not allowed while "strict subs" in use at -e line 1. Execution of -e aborted due to compilation errors. TL;DR: `false` is not a keyword and (in non-strict mode) becomes the string `"false"`, which is true.<|eor|><|eoss|><|endoftext|>
7
lolphp
Silly-Freak
hvyibi1
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>Use parenthesis.<|eor|><|sor|>It is not a help post it's a lol post. The OP thinks this behavior is somewhat ridiculous and expects it to be fixed in some future version.<|eor|><|sor|>I don't think people expect the lols they post to be fixed. If they did, they'd post it in an issue tracker...<|eor|><|eoss|><|endoftext|>
6
lolphp
Silly-Freak
hvym6vh
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>Thats not a lol. Thats failure to read documentation. If you want a lol, read up on the SPL structures that tell you that `top()` peeks at the node from the end and `bottom()` peeks at the node from the beginning.<|eor|><|sor|>>Thats not a lol. Thats failure to read documentation. Sometimes, things work as documented but are still bad. Why would you ever want `and` to have lower precedence than `=`? The only explanation I can see is legacy compatibility.<|eor|><|sor|>Well it gives you a possibility to write neat code like in perl or bash. I make it, we should expect someone to post here a lol about logical operators' laziness, expecting that OR should evaluate both expressions no matter if the first one already returned a truey result.<|eor|><|sor|>Not that there's anything inherently wrong with that, but we seem to have different definitions of "neat". I can imagine how this probably started out: - in the beginning we had short-circuiting `||` - people realized that `foo() || die();` is shorter than `if(!foo()) die();` so they wrote that - in addition to `die()`, people started to do things like `foo() || report_falsy_foo();` - people realized that `$x = foo() || report_falsy_foo();` didn't do what they wanted - thus, `or` was introduced while `if` was there the whole time Imagining this (approximation of the actual) history, it makes sense to have both `||` and `or` with their peculiar difference - but without that context, it is totally unclear why there are two logical or operators, why they work differently, or why there are operators that don't have precedence over assignment at all. This behavior is very much grounded in a specific niche use case and not in what the logical-or operation means. IMO this is absolutely a lol, even if it's not new.<|eor|><|eoss|><|endoftext|>
6
lolphp
operator--
hvyto2f
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>Thats not a lol. Thats failure to read documentation. If you want a lol, read up on the SPL structures that tell you that `top()` peeks at the node from the end and `bottom()` peeks at the node from the beginning.<|eor|><|sor|>>Thats not a lol. Thats failure to read documentation. Sometimes, things work as documented but are still bad. Why would you ever want `and` to have lower precedence than `=`? The only explanation I can see is legacy compatibility.<|eor|><|sor|>Well it gives you a possibility to write neat code like in perl or bash. I make it, we should expect someone to post here a lol about logical operators' laziness, expecting that OR should evaluate both expressions no matter if the first one already returned a truey result.<|eor|><|sor|>>write neat code like in perl or bash I chuckled.<|eor|><|eoss|><|endoftext|>
6
lolphp
SaltineAmerican_1970
hvxs4h0
<|soss|><|sot|>Operator precedence<|eot|><|sost|>These two lines are not equivalent. <?php $a = true && false; // false $b = true and false; // true Because `&&` and `||` have different operator priority than `and` and `or` (the latter ones have lower priority than `=`). [Source](https://www.php.net/manual/en/language.operators.precedence.php#117390). Still the case [in PHP 8.1](https://3v4l.org/S1qmT).<|eost|><|sor|>Thats not a lol. Thats failure to read documentation. If you want a lol, read up on the SPL structures that tell you that `top()` peeks at the node from the end and `bottom()` peeks at the node from the beginning.<|eor|><|eoss|><|endoftext|>
5
lolphp
phplovesong
jp6d11
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|eoss|><|endoftext|>
38
lolphp
wweber
gbd3f17
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Lol `continue 2` is seriously the correct way to `continue`?<|eor|><|sor|>php announces highly anticipated sequel to `continue`<|eor|><|eoss|><|endoftext|>
31
lolphp
CarnivorousSociety
gbd2yup
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Lol `continue 2` is seriously the correct way to `continue`?<|eor|><|sor|>because php treats the switch as a control structure and `continue` is equivalent to `break` \#reasons https://www.php.net/manual/en/control-structures.continue.php > **Note:** In PHP the switch statement is considered a looping structure for the purposes of continue. continue behaves like break (when no arguments are passed) but will raise a warning as this is likely to be a mistake. If a switch is inside a loop, continue 2 will continue with the next iteration of the outer loop.<|eor|><|sor|>Most lolphp's I see are just cases of badly understood implicit type conversions, like 99% of them. But this is actually retarded<|eor|><|eoss|><|endoftext|>
22
lolphp
iamcgn
gbcvymf
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Lol `continue 2` is seriously the correct way to `continue`?<|eor|><|eoss|><|endoftext|>
19
lolphp
bkdotcom
gbd82fi
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Lol `continue 2` is seriously the correct way to `continue`?<|eor|><|sor|>php announces highly anticipated sequel to `continue`<|eor|><|sor|>https://www.php.net/manual/en/control-structures.continue.php > continue accepts an optional numeric argument which tells it how many levels of enclosing loops it should skip to the end of. The default value is 1, thus skipping to the end of the current loop. > **Note**: In PHP the switch statement is considered a looping structure for the purposes of continue. continue behaves like break (when no arguments are passed) but will raise a warning as this is likely to be a mistake. If a switch is inside a loop, continue 2 will continue with the next iteration of the outer loop.<|eor|><|eoss|><|endoftext|>
18
lolphp
bkdotcom
gbczgfa
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Beginning with PHP 7.3 Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in<|eor|><|eoss|><|endoftext|>
12
lolphp
bkdotcom
gbczmlg
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Lol `continue 2` is seriously the correct way to `continue`?<|eor|><|sor|>because php treats the switch as a control structure and `continue` is equivalent to `break` \#reasons https://www.php.net/manual/en/control-structures.continue.php > **Note:** In PHP the switch statement is considered a looping structure for the purposes of continue. continue behaves like break (when no arguments are passed) but will raise a warning as this is likely to be a mistake. If a switch is inside a loop, continue 2 will continue with the next iteration of the outer loop.<|eor|><|eoss|><|endoftext|>
9
lolphp
elcapitanoooo
gbynmle
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Lol `continue 2` is seriously the correct way to `continue`?<|eor|><|sor|>php announces highly anticipated sequel to `continue`<|eor|><|sor|>that's actually a thing PHP got right. if C had `continue X` / `break X` support too, there would be fewer goto's, it's a better alternative to goto to break out of deeply nested loops. take for example searching for a smaller image inside a bigger image: ```php for($x = 0; $x < $bigx; ++ $x) { if ($bigx < ($x + $smallx)) {//<< todo: can be optimized away. break; // too close to the end, no result possible.. } for($y = 0; $y < $bigy; ++ $y) { if ($bigy < ($y + $smally)) {//<< todo: can be optimized away. continue; // too close to the bottom, no result possible for this $y.. } for($i = 0; $i < $smallx; ++ $i) { for($ii = 0; $ii < $smally; ++ $ii) { if($smallImageAsColors [$i][$ii]!==imagecolorat($big,$x+$i,$y+$ii)) { continue 3; } } } $ret [] = array ( 'x' => ($center?$x+((int)floor($smallx/2)):$x), 'y' => ($center?$y+((int)floor($smally/2)):$y) ); if (count ( $ret ) >= $max) { return $ret; } } } ``` - in PHP you can write `continue 3`, in C you'd use goto instead..<|eor|><|sor|>Whenever i see a continue N i see a code smell. A real bad one too.<|eor|><|sor|>what about when you see `goto lbl;` ?<|eor|><|sor|>Same. I have not personally used a goto statement in the last 10 years. In fact i dont think i have ever used a goto statement in production code. I dare to say its common knowledge that goto statements are bad in may ways and should be avoided. There is many better abstractions or ways to write code than goto. goto is ultimately what the cpu ends up doing, and the compiler should be able to handle this in a way the programmer wont have to deal with gotos.<|eor|><|sor|>the Linux Kernel frequently use `goto` to jump to cleanup code on error conditions, check this: https://github.com/torvalds/linux/search?l=C&q=goto and while i rarely use goto myself, it does happen sometimes to get out of deeply nested for-loops<|eor|><|sor|>Yes, thats some very low level code. Write assembly, low level systems programming or gpu code, sure fine use goto and fine tune for perf. Im talking about higher level languages with maps, filters, hocs etc. I want to write how i express my ideas, not what the computer does. Declarative code and let the compiler handle the fine tuning.<|eor|><|eoss|><|endoftext|>
6
lolphp
Takeoded
gbhtzaf
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Lol `continue 2` is seriously the correct way to `continue`?<|eor|><|sor|>php announces highly anticipated sequel to `continue`<|eor|><|sor|>that's actually a thing PHP got right. if C had `continue X` / `break X` support too, there would be fewer goto's, it's a better alternative to goto to break out of deeply nested loops. take for example searching for a smaller image inside a bigger image: ```php for($x = 0; $x < $bigx; ++ $x) { if ($bigx < ($x + $smallx)) {//<< todo: can be optimized away. break; // too close to the end, no result possible.. } for($y = 0; $y < $bigy; ++ $y) { if ($bigy < ($y + $smally)) {//<< todo: can be optimized away. continue; // too close to the bottom, no result possible for this $y.. } for($i = 0; $i < $smallx; ++ $i) { for($ii = 0; $ii < $smally; ++ $ii) { if($smallImageAsColors [$i][$ii]!==imagecolorat($big,$x+$i,$y+$ii)) { continue 3; } } } $ret [] = array ( 'x' => ($center?$x+((int)floor($smallx/2)):$x), 'y' => ($center?$y+((int)floor($smally/2)):$y) ); if (count ( $ret ) >= $max) { return $ret; } } } ``` - in PHP you can write `continue 3`, in C you'd use goto instead..<|eor|><|eoss|><|endoftext|>
5
lolphp
nikic
gbtexvi
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Please, can you use 3v4l when submitting code snippets to this reddit? Especially for /r/lolphp seeing how code behaves across different PHP versions is helpful: https://3v4l.org/ov0K9<|eor|><|soopr|>Why does it matter? Its still broken, and wont be fixed any time soon. In fact, bugs like this are never going to be fixed.<|eoopr|><|sor|>In this particular case, LOL #3 has been mitigated in PHP 7.4 and LOL #2 has been fixed entirely in PHP 8.0. It's relevant information.<|eor|><|eoss|><|endoftext|>
5
lolphp
elcapitanoooo
gbxde73
<|soss|><|sot|>PHP: Cast away<|eot|><|sost|>PHP likes to cast like theres no tomorrow. Also PHP leaks the "continue" statement, and if given, actually uses it inside a switch as a break. So now switches have two ways of doing the same thing, why? Probably because to have the most inconsistent API in the world of programming. [https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa](https://sandbox.onlinephpfunctions.com/code/bae156e37fa3cfd64d2a68d689434fe7157543fa)<|eost|><|sor|>Lol `continue 2` is seriously the correct way to `continue`?<|eor|><|sor|>php announces highly anticipated sequel to `continue`<|eor|><|sor|>that's actually a thing PHP got right. if C had `continue X` / `break X` support too, there would be fewer goto's, it's a better alternative to goto to break out of deeply nested loops. take for example searching for a smaller image inside a bigger image: ```php for($x = 0; $x < $bigx; ++ $x) { if ($bigx < ($x + $smallx)) {//<< todo: can be optimized away. break; // too close to the end, no result possible.. } for($y = 0; $y < $bigy; ++ $y) { if ($bigy < ($y + $smally)) {//<< todo: can be optimized away. continue; // too close to the bottom, no result possible for this $y.. } for($i = 0; $i < $smallx; ++ $i) { for($ii = 0; $ii < $smally; ++ $ii) { if($smallImageAsColors [$i][$ii]!==imagecolorat($big,$x+$i,$y+$ii)) { continue 3; } } } $ret [] = array ( 'x' => ($center?$x+((int)floor($smallx/2)):$x), 'y' => ($center?$y+((int)floor($smally/2)):$y) ); if (count ( $ret ) >= $max) { return $ret; } } } ``` - in PHP you can write `continue 3`, in C you'd use goto instead..<|eor|><|sor|>Whenever i see a continue N i see a code smell. A real bad one too.<|eor|><|eoss|><|endoftext|>
5
lolphp
shitcanz
bznl3l
<|soss|><|sot|>Meanwhile in PHP RFC<|eot|><|sost|>PHP has such amazing innovation going on.. https://wiki.php.net/rfc/tostring_exceptions<|eost|><|eoss|><|endoftext|>
36
lolphp
AlGoreBestGore
equdjtj
<|soss|><|sot|>Meanwhile in PHP RFC<|eot|><|sost|>PHP has such amazing innovation going on.. https://wiki.php.net/rfc/tostring_exceptions<|eost|><|sor|>The workaround in Symfony is also pretty gnarly https://github.com/symfony/symfony/blob/1c110fa1f7e3e9f5daba73ad52d9f7e843a7b3ff/src/Symfony/Component/Debug/ErrorHandler.php?utm_source=share&utm_medium=ios_app#L457-L489.<|eor|><|eoss|><|endoftext|>
20
lolphp
dotancohen
equ2ia6
<|soss|><|sot|>Meanwhile in PHP RFC<|eot|><|sost|>PHP has such amazing innovation going on.. https://wiki.php.net/rfc/tostring_exceptions<|eost|><|sor|>This one is a real mess. I'm sitting on both sides of the fence here. Special-casing \_\_toString() was silly.<|eor|><|eoss|><|endoftext|>
10
lolphp
janvt
er4z4bo
<|soss|><|sot|>Meanwhile in PHP RFC<|eot|><|sost|>PHP has such amazing innovation going on.. https://wiki.php.net/rfc/tostring_exceptions<|eost|><|sor|>The workaround in Symfony is also pretty gnarly https://github.com/symfony/symfony/blob/1c110fa1f7e3e9f5daba73ad52d9f7e843a7b3ff/src/Symfony/Component/Debug/ErrorHandler.php?utm_source=share&utm_medium=ios_app#L457-L489.<|eor|><|sor|>This?!? In Symfony?!? I have not seen such a mess in PHP for the better part of a decade. Go through that method's history, you can see that this is even the cleaned-up version after HipHop support had been removed two years ago.<|eor|><|sor|>There is a lot of deliciously dirty code in Symfony, especially in places where they prevent BC breaks. But, the main thing is the public interfaces are (mostly) stable, clean and sensible.<|eor|><|eoss|><|endoftext|>
9
lolphp
dotancohen
er03rgx
<|soss|><|sot|>Meanwhile in PHP RFC<|eot|><|sost|>PHP has such amazing innovation going on.. https://wiki.php.net/rfc/tostring_exceptions<|eost|><|sor|>The workaround in Symfony is also pretty gnarly https://github.com/symfony/symfony/blob/1c110fa1f7e3e9f5daba73ad52d9f7e843a7b3ff/src/Symfony/Component/Debug/ErrorHandler.php?utm_source=share&utm_medium=ios_app#L457-L489.<|eor|><|sor|>This?!? In Symfony?!? I have not seen such a mess in PHP for the better part of a decade. Go through that method's history, you can see that this is even the cleaned-up version after HipHop support had been removed two years ago.<|eor|><|eoss|><|endoftext|>
5
lolphp
phplovesong
bblr7x
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|eoss|><|endoftext|>
40
lolphp
Miserable_Fuck
ekjziir
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>I love how r/lolphp is full of php apologists <|eor|><|eoss|><|endoftext|>
27
lolphp
SirClueless
ekjzy3u
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>Basically everything in that article is either: 1. Already fixed in the latest release. 2. Is a known issue and is planned to be fixed. 3. Just a language quirk which if fixed would break too much code and so PHP devs have just learnt to live with. It's somewhat expected that a language as old as PHP would have some of this. There's probably some things that fall into none of those categories and should be drawn attention to, but I'm personally impressed with how much cleaning up has been done in the 7.x releases.<|eor|><|sor|>1. is legitimate. Lots of things have been improved and PHP has many improvements since 5.0. 2. is passing the buck. When are these fixes coming? PHP has had seven years and a major version bump, if known issues from 2012 haven't been addressed how am I supposed to have any confidence they ever will be? 3. is just an excuse. When you explain something as a historical accident that can't be improved, you're explaining *how* the language developed its issues, not giving me a reason to tolerate those issues in 2019. Lots of other languages with less historical baggage have avoided or resolved those issues in the meantime, why shouldn't I use one of them instead?<|eor|><|eoss|><|endoftext|>
25
lolphp
redwall_hp
ekkayl5
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>Numero uno is still a thing and never going to change the the entire language is predicated on this method of stupidity: the notion that it's better to fuck up data and keep chugging instead of throwing errors and stopping. Everything with the type coercion is an antipattern. It's just bad. PHP "arrays" are just...bad and they should feel bad. One data structure is trying to behave like a list and a dictionary, and doing poorly at both. And it's all implemented on a hash table. All of the C-style top level functions for manipulating them will happily do their thing without regard for what kind of data is in the structure, doing potentially unexpected things and destroying data without any indication of what happened. So you can have your script run and behave in bizarre ways, and have no hint as to what the hell is going wrong when you made a mistake. Because it's opaque at a glance and not easy for a linter to flag.<|eor|><|eoss|><|endoftext|>
22
lolphp
Miserable_Fuck
ekyt4gl
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>I love how r/lolphp is full of php apologists <|eor|><|sor|>The people in r/php monitor this subreddit and send the brute squad to contest every little criticism. They think they are doing the language a favor and cleaning up its reputation.<|eor|><|sor|>Here's a sneak peek of /r/PHP using the [top posts](https://np.reddit.com/r/PHP/top/?sort=top&t=year) of the year! \#1: [Used PHP in a Hackathon was made fun of and it made me feel really shitty.](https://np.reddit.com/r/PHP/comments/8ed9tt/used_php_in_a_hackathon_was_made_fun_of_and_it/) \#2: [$emergency](https://i.redd.it/81besxu7lxy01.jpg) | [10 comments](https://np.reddit.com/r/PHP/comments/8kq9ke/emergency/) \#3: [on PHP7 by the Creator of PHP. Must watch!!! He is so awesome!](https://youtu.be/rKXFgWP-2xQ) | [38 comments](https://np.reddit.com/r/PHP/comments/8m5tu5/on_php7_by_the_creator_of_php_must_watch_he_is_so/) ---- ^^I'm ^^a ^^bot, ^^beep ^^boop ^^| ^^Downvote ^^to ^^remove ^^| [^^Contact ^^me](https://www.reddit.com/message/compose/?to=sneakpeekbot) ^^| [^^Info](https://np.reddit.com/r/sneakpeekbot/) ^^| [^^Opt-out](https://np.reddit.com/r/sneakpeekbot/comments/afd0dd/blacklist/)<|eor|><|sor|>I suspected this too some time back. I checked a bunch of threads and noticed a pattern with certain users. I then checked their posting history and quite a few of them were avid r/PHP posters. I believe one of them was even part of the actual PHP dev team, or used to be. I'm not saying everyone who posts here is a paid shill or something, but there does seem to be a small concerted effort going on.<|eor|><|sor|>Or maybe we can use a language but also criticise it for its shortcomings? Crazy thought right<|eor|><|sor|>No you're not understanding. The users I noticed were always *defending* PHP in the comments. Criticizing PHP is fine, that's what this sub is for.<|eor|><|eoss|><|endoftext|>
11
lolphp
jesseschalken
ekju1dt
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>Basically everything in that article is either: 1. Already fixed in the latest release. 2. Is a known issue and is planned to be fixed. 3. Just a language quirk which if fixed would break too much code and so PHP devs have just learnt to live with. It's somewhat expected that a language as old as PHP would have some of this. There's probably some things that fall into none of those categories and should be drawn attention to, but I'm personally impressed with how much cleaning up has been done in the 7.x releases.<|eor|><|eoss|><|endoftext|>
10
lolphp
BrianBoyko
el90bbh
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>Basically everything in that article is either: 1. Already fixed in the latest release. 2. Is a known issue and is planned to be fixed. 3. Just a language quirk which if fixed would break too much code and so PHP devs have just learnt to live with. It's somewhat expected that a language as old as PHP would have some of this. There's probably some things that fall into none of those categories and should be drawn attention to, but I'm personally impressed with how much cleaning up has been done in the 7.x releases.<|eor|><|sor|>1. is legitimate. Lots of things have been improved and PHP has many improvements since 5.0. 2. is passing the buck. When are these fixes coming? PHP has had seven years and a major version bump, if known issues from 2012 haven't been addressed how am I supposed to have any confidence they ever will be? 3. is just an excuse. When you explain something as a historical accident that can't be improved, you're explaining *how* the language developed its issues, not giving me a reason to tolerate those issues in 2019. Lots of other languages with less historical baggage have avoided or resolved those issues in the meantime, why shouldn't I use one of them instead?<|eor|><|sor|>>is passing the buck. When are these fixes coming? PHP has had seven years and a major version bump, if known issues from 2012 haven't been addressed how am I supposed to have any confidence they ever will be? It has been slow, indeed. What are you going to do about it? >is just an excuse. When you explain something as a historical accident that can't be improved, you're explaining how the language developed its issues, not giving me a reason to tolerate those issues in 2019. Lots of other languages with less historical baggage have avoided or resolved those issues in the meantime, why shouldn't I use one of them instead? It's easy to look at some quirk and say "this is bullshit, fix it" but there's mountains of code piled up on top of the PHP language and stability is a legitimate value. You can run roughshod over all the existing code fixing all the quirks and breaking all the things, and nobody will upgrade to your shiny new version. A language, especially an old one, doesn't just exist for the purpose of greenfield projects. It also exists to support existing projects that want both stability *and* improvements and fixes with clear and feasible migration paths that aren't prohibitively costly.<|eor|><|sor|>>It has been slow, indeed. What are you going to do about it? Not use PHP. >It's easy to look at some quirk and say "this is bullshit, fix it" but there's mountains of code piled up on top of the PHP language and stability is a legitimate value. You can run roughshod over all the existing code fixing all the quirks and breaking all the things, and nobody will upgrade to your shiny new version. > >A language, especially an old one, doesn't just exist for the purpose of greenfield projects. It also exists to support existing projects that want both stability *and* improvements and fixes with clear and feasible migration paths that aren't prohibitively costly. Well, see, that's kind of the problem. It's called Technical Debt. And it's like Credit Card debt. Sometimes you have to put something on the Technical Credit Card. Usually it's something small - it should be like \*this\*, but it had to be like \*that\* to meet deadline/budget/whatever. And if you pay that debt off by fixing your outstanding issues before adding new features, and make incremental changes, it's relatively easy to maintain what you have and grow new features. This is especially true if you follow the principle of highly cohesive, loosely coupled code, where interests are separated from one another, and messing with Module A doesn't affect Module Q or something. What PHP, however, has done, is prioritized adding new features over fixing the things they really ought to have fixed - partially because of the development attitude that something is "done" when it works "well enough" in "most cases", instead of, you know, testing for that, fixing errors when they happen, etc. Nothing one does in PHP is worth doing well, it seems. At this point, maintaining PHP just isn't worth it. That technical debt has exploded into Technical Bankruptcy - in the amount of time it would take to fix the issues with PHP, it would be simpler and quicker to write a new language with the goals of PHP from scratch. (Arguably, that's *exactly* what Ruby on Rails was.) That's true for most PHP applications still in use - it is getting to the point that developers don't want to work with PHP, and developers are *not spoiled for choice* when looking for work. It is so bad, last year, one company actually tried to *catfish* me, by having the job posting, technical interviews, take-home-assignment, and introduction be all about my JS development and the JS ecosystem, and then when I sat down at that job, they sat me in front of PHPstorm and told me my job would be almost entirely PHP, and that, yes, they asked me about my JS, but that I was a smart guy and could easily "pick up" PHP. I quit after two and a half days. The second day was me mostly asking if the job could be salvaged by moving to another department. The half-day was so that I could write up a formal letter of resignation. At this point, if a company is using PHP and they're seeking my expert opinion, I tell them that the sooner they can replace PHP with something else, the more money they will save in the long run, as they will have to pay much, much more for developers who are willing to torture themselves to maintain PHP as fewer and fewer people bother with learning the language (simple supply and demand.)<|eor|><|eoss|><|endoftext|>
10
lolphp
SituationSoap
ekke0nv
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>I love how r/lolphp is full of php apologists <|eor|><|sor|>Familiarity breeds contempt. In PHP's case, very deserved contempt.<|eor|><|eoss|><|endoftext|>
9
lolphp
TheBuzzSaw
ekpwv2w
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>I love how r/lolphp is full of php apologists <|eor|><|sor|>The people in r/php monitor this subreddit and send the brute squad to contest every little criticism. They think they are doing the language a favor and cleaning up its reputation.<|eor|><|eoss|><|endoftext|>
6
lolphp
phplovesong
ekm8vtw
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>[deleted]<|eor|><|soopr|>Strict types dont help. Lots of the criticism is purely based on the shitty stdlib and the deep inconsistency php has. No new feature can fix the big issues without a BC breaking change. Core PHP is still the same it was in PHP4 and PHP5, nothing introduced has really been fixed, some things have been lipsticked with a random boolean third of fourth value to change some behaviour.<|eoopr|><|eoss|><|endoftext|>
6
lolphp
SirClueless
ekl8s5e
<|soss|><|sot|>PHP: a fractal of bad design - 7 years old and still relevant<|eot|><|sost|>One of the best articles describing the true nature of PHP is 7 years old! This article has made multiple rounds on the internet, and 1000s of developers have probably learnt what PHP truly is. In these 7 years many of t issues the article explains are still part of the core, without a fix or patch. [https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)<|eost|><|sor|>Basically everything in that article is either: 1. Already fixed in the latest release. 2. Is a known issue and is planned to be fixed. 3. Just a language quirk which if fixed would break too much code and so PHP devs have just learnt to live with. It's somewhat expected that a language as old as PHP would have some of this. There's probably some things that fall into none of those categories and should be drawn attention to, but I'm personally impressed with how much cleaning up has been done in the 7.x releases.<|eor|><|sor|>1. is legitimate. Lots of things have been improved and PHP has many improvements since 5.0. 2. is passing the buck. When are these fixes coming? PHP has had seven years and a major version bump, if known issues from 2012 haven't been addressed how am I supposed to have any confidence they ever will be? 3. is just an excuse. When you explain something as a historical accident that can't be improved, you're explaining *how* the language developed its issues, not giving me a reason to tolerate those issues in 2019. Lots of other languages with less historical baggage have avoided or resolved those issues in the meantime, why shouldn't I use one of them instead?<|eor|><|sor|>>is passing the buck. When are these fixes coming? PHP has had seven years and a major version bump, if known issues from 2012 haven't been addressed how am I supposed to have any confidence they ever will be? It has been slow, indeed. What are you going to do about it? >is just an excuse. When you explain something as a historical accident that can't be improved, you're explaining how the language developed its issues, not giving me a reason to tolerate those issues in 2019. Lots of other languages with less historical baggage have avoided or resolved those issues in the meantime, why shouldn't I use one of them instead? It's easy to look at some quirk and say "this is bullshit, fix it" but there's mountains of code piled up on top of the PHP language and stability is a legitimate value. You can run roughshod over all the existing code fixing all the quirks and breaking all the things, and nobody will upgrade to your shiny new version. A language, especially an old one, doesn't just exist for the purpose of greenfield projects. It also exists to support existing projects that want both stability *and* improvements and fixes with clear and feasible migration paths that aren't prohibitively costly.<|eor|><|sor|>I'm not questioning their decision making. Keeping a bunch of questionable behavior and inconsistent standard library functions in order to keep supporting the mountain of legacy code that runs on PHP is a legitimate tradeoff. This sub exists to laugh at the lamentable features of PHP that everyone will have to deal with for the foreseeable future because the language can't fix them. If these things were fixable bugs, they'd belong on the PHP bug tracker, not on a comedy subreddit.<|eor|><|eoss|><|endoftext|>
6
lolphp
malachias
8bham9
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|eoss|><|endoftext|>
36
lolphp
kasnalin
dx75x0z
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>`or` is pretty explicitly designed for control flow in the Perl style: $retval = operation_that_returns_false_on_failure() or die(); I don't know if I can hold this against PHP. Confusing `||` with `or` is like confusing `||` with `|`, which is present in a bunch of languages.<|eor|><|eoss|><|endoftext|>
23
lolphp
inabahare
dx7ebrp
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>`or` is pretty explicitly designed for control flow in the Perl style: $retval = operation_that_returns_false_on_failure() or die(); I don't know if I can hold this against PHP. Confusing `||` with `or` is like confusing `||` with `|`, which is present in a bunch of languages.<|eor|><|sor|>$a or $b TRUE if either $a or $b is TRUE. $a || $b TRUE if either $a or $b is TRUE. I mean, this is the first thing that you're greeted with hen you look at the operators, and you'd have to scroll down to the examples where they show the difference, and I wonder how many scrolls down there (or how many teachers don't actually tell their students) Also, it's really nothing like the difference between boolean and bitwise or<|eor|><|eoss|><|endoftext|>
13
lolphp
inabahare
dxenycv
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>`or` is pretty explicitly designed for control flow in the Perl style: $retval = operation_that_returns_false_on_failure() or die(); I don't know if I can hold this against PHP. Confusing `||` with `or` is like confusing `||` with `|`, which is present in a bunch of languages.<|eor|><|sor|>$a or $b TRUE if either $a or $b is TRUE. $a || $b TRUE if either $a or $b is TRUE. I mean, this is the first thing that you're greeted with hen you look at the operators, and you'd have to scroll down to the examples where they show the difference, and I wonder how many scrolls down there (or how many teachers don't actually tell their students) Also, it's really nothing like the difference between boolean and bitwise or<|eor|><|sor|>shouldn't `|` be `bitwise_or` ?<|eor|><|sor|>I belive PHP supports | just the same<|eor|><|sor|>Hey, inabahare, just a quick heads-up: **belive** is actually spelled **believe**. You can remember it by **i before e**. Have a nice day! ^^^^The ^^^^parent ^^^^commenter ^^^^can ^^^^reply ^^^^with ^^^^'delete' ^^^^to ^^^^delete ^^^^this ^^^^comment.<|eor|><|sor|>Your not my dad<|eor|><|eoss|><|endoftext|>
10
lolphp
HildartheDorf
dx6p19u
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>>yes, x is '0' What.<|eor|><|eoss|><|endoftext|>
9
lolphp
cfreak2399
dx7u4ru
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>`or` is pretty explicitly designed for control flow in the Perl style: $retval = operation_that_returns_false_on_failure() or die(); I don't know if I can hold this against PHP. Confusing `||` with `or` is like confusing `||` with `|`, which is present in a bunch of languages.<|eor|><|sor|>Yeah this is more lolperl than lolphp. I'm pretty sure Perl gives you the same result since `||` has higher precedence than `or` there too. PHP borrowed a lot from Perl in the early days I think `if( $x = $a || $b )` would be a syntax error in Perl. (it's been many years since I've coded in it though) <|eor|><|eoss|><|endoftext|>
8
lolphp
malachias
dx6spd3
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>>yes, x is '0' What.<|eor|><|soopr|>Yeah. So operator precedence is at play here, specifically '||' is stronger than '=' is stronger than 'or'. So: if ($x = $a or $b) is basically equivalent to if (($x = $a) || $b) The first clause sets $x to 0 then yields the value of $x, so the guard then becomes equivalent to if (0 || 1) which evaluates to true, allowing execution to pass the if-guard while setting $x to 0. I guess this is as good a reminder as any that the `if ($var = [stuff])` pattern is not necessarily equivalent to `$var = [stuff]; if ($var)` as it is commonly used.<|eoopr|><|eoss|><|endoftext|>
8
lolphp
malachias
dx6sthb
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>I'll be the straight man. I think the output is: yes yes x: 1 x: true yes, x is '1' yes, x is 'true'<|eor|><|sor|> yes yes x: 1 x: 0 yes, x is '1' yes, x is '0' I mean, close enough<|eor|><|soopr|>eh, in the grand scheme of things, do the values of a couple of booleans really matter? ;)<|eoopr|><|eoss|><|endoftext|>
8
lolphp
inabahare
dx6p40n
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>I'll be the straight man. I think the output is: yes yes x: 1 x: true yes, x is '1' yes, x is 'true'<|eor|><|sor|> yes yes x: 1 x: 0 yes, x is '1' yes, x is '0' I mean, close enough<|eor|><|eoss|><|endoftext|>
7
lolphp
malachias
dxbbt0m
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>>yes, x is '0' What.<|eor|><|soopr|>Yeah. So operator precedence is at play here, specifically '||' is stronger than '=' is stronger than 'or'. So: if ($x = $a or $b) is basically equivalent to if (($x = $a) || $b) The first clause sets $x to 0 then yields the value of $x, so the guard then becomes equivalent to if (0 || 1) which evaluates to true, allowing execution to pass the if-guard while setting $x to 0. I guess this is as good a reminder as any that the `if ($var = [stuff])` pattern is not necessarily equivalent to `$var = [stuff]; if ($var)` as it is commonly used.<|eoopr|><|sor|> > if ($x = $a or $b) > This will always be true because it is an assignment, not a comparison.<|eor|><|soopr|>Assignments yield the value assigned, not true-if-assignment-happened. As such, if $a and $b are both 0, then it will not be true. A common pattern you see this used in is something like // process_thing() returns false or some truthy value if ($result = process_thing($other_thing)) { // can refer to $result here }<|eoopr|><|eoss|><|endoftext|>
7
lolphp
Various_Pickles
dxdjpjb
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>The output will, like all invocations of the PHP runtime interpreter, be an incantation aimed at opening a transdimensional gateway to the endless desert realm of the race of half-scorpion, half-man monsters that created PHP in an effort to resurrect their dead lich king.<|eor|><|eoss|><|endoftext|>
6
lolphp
fell_ratio
dx6oqqq
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>I'll be the straight man. I think the output is: yes yes x: 1 x: true yes, x is '1' yes, x is 'true'<|eor|><|eoss|><|endoftext|>
5
lolphp
OneWingedShark
dx80ngq
<|soss|><|sot|>Logical or: "||" vs "or"<|eot|><|sost|>PHP supports both. Now, without googling or throwing it into a REPL, who can tell me what this outputs? $a = 0; $b = 1; if ($a || $b) echo "yes\n"; if ($a or $b) echo "yes\n"; $x = $a || $b; echo "x: $x\n"; $x = $a or $b; echo "x: $x\n"; if ($x = $a || $b) echo "yes, x is '$x'\n"; if ($x = $a or $b) echo "yes, x is '$x'\n";<|eost|><|sor|>I'll be the straight man. I think the output is: yes yes x: 1 x: true yes, x is '1' yes, x is 'true'<|eor|><|sor|> yes yes x: 1 x: 0 yes, x is '1' yes, x is '0' I mean, close enough<|eor|><|soopr|>eh, in the grand scheme of things, do the values of a couple of booleans really matter? ;)<|eoopr|><|sor|>`$life_support_active = true`?<|eor|><|eoss|><|endoftext|>
5
lolphp
prewk
77kssu
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|eols|><|endoftext|>
37
lolphp
Various_Pickles
domqgs1
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|sor|>I like how fucking none of PHP's array_*, implode, explode, etc functions work with anything but actual, explicit arrays. Go write your own core library ~~Traversable~~ iterable!<|eor|><|eols|><|endoftext|>
25
lolphp
sloat
domywv2
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|soopr|>We had the usual problems with filtering normal arrays requiring `array_values` to keep it from turning into an object when JSON encoding (holes in PHP's "array" turns it into a hashmap). So I looked for a more sensible array type - `SplFixedArray` - but that JSON encodes into an object _by default_ for no reason?<|eoopr|><|sor|>Just because an object has the word *array* in its name doesn't mean it's not an object. You can call objects whatever you like; it's just a name.<|eor|><|sor|>> Just because an object has the word array in its name doesn't mean it's not an object. That's one for *The Zen of PHP*: Just because it's called something, doesn't mean it is that thing.<|eor|><|eols|><|endoftext|>
23
lolphp
Xymanek
domsb33
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|soopr|>We had the usual problems with filtering normal arrays requiring `array_values` to keep it from turning into an object when JSON encoding (holes in PHP's "array" turns it into a hashmap). So I looked for a more sensible array type - `SplFixedArray` - but that JSON encodes into an object _by default_ for no reason?<|eoopr|><|sor|>Yes, PHP arrays are technically maps. I'm curious to hear what holes you're talking about, because in my experience it's not a common occurrence for a properly formatted JSON array to json_decode into something that isn't an array.<|eor|><|sor|>> I'm curious to hear what holes you're talking about * PHP: `[0]` -> JSON `[0]` * PHP: `[]` -> JSON `{}` This breaks things like JS array iteration<|eor|><|eols|><|endoftext|>
15
lolphp
mardukaz1
domsjs7
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|sor|>I like how fucking none of PHP's array_*, implode, explode, etc functions work with anything but actual, explicit arrays. Go write your own core library ~~Traversable~~ iterable!<|eor|><|sor|>Well, they'd all have to be completely rewritten to work on things that aren't real arrays.<|eor|><|sor|>Fair enough, as, under the hood, walking through a C array is (likely) tremendously more efficient than invoking an iterator. However, the language as a whole seems to be basically becoming shitty python, so having a core library that works with sequences is inevitable/required. The lolphp is palatable. Edit: Also, what sort of clown language adds operator level support (foreach) to a new concept before there is a single bit of the core library that understands what that thing is?<|eor|><|sor|>> Also, what sort of clown language adds operator level support (foreach) to a new concept before there is a single bit of the core library that understands what that thing is? I'll give it a go - PHP?<|eor|><|eols|><|endoftext|>
14
lolphp
Various_Pickles
domr2j1
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|sor|>I like how fucking none of PHP's array_*, implode, explode, etc functions work with anything but actual, explicit arrays. Go write your own core library ~~Traversable~~ iterable!<|eor|><|sor|>Well, they'd all have to be completely rewritten to work on things that aren't real arrays.<|eor|><|sor|>Fair enough, as, under the hood, walking through a C array is (likely) tremendously more efficient than invoking an iterator. However, the language as a whole seems to be basically becoming shitty python, so having a core library that works with sequences is inevitable/required. The lolphp is palatable. Edit: Also, what sort of clown language adds operator level support (foreach) to a new concept before there is a single bit of the core library that understands what that thing is?<|eor|><|eols|><|endoftext|>
13
lolphp
prewk
domwses
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|soopr|>We had the usual problems with filtering normal arrays requiring `array_values` to keep it from turning into an object when JSON encoding (holes in PHP's "array" turns it into a hashmap). So I looked for a more sensible array type - `SplFixedArray` - but that JSON encodes into an object _by default_ for no reason?<|eoopr|><|sor|>Yes, PHP arrays are technically maps. I'm curious to hear what holes you're talking about, because in my experience it's not a common occurrence for a properly formatted JSON array to json_decode into something that isn't an array.<|eor|><|soopr|>Here's an example: $stuff = ["foo", "bar", "baz"]; // json_encodes into ["foo","bar","baz"] $filtered = array_filter($stuff, function($val) { return $val[0] === "b"; }); // json_encodes into {"1":"bar","2":"baz"} $filtered = array_values($filtered); // json_encodes into ["bar","baz"] I'm fully aware that PHP arrays are maps and that they have this behavior. It's a core thing in PHP which I'm not very fond of but it's not what I'm complaining about. What I'm complaining about is that the one built-in tool that's supposed to NOT have this problem seems to be: [SplFixedArray](http://se2.php.net/manual/en/class.splfixedarray.php). `SplFixedArray` _can't_ have non-integer "keys", nor can it have non-sequential keys. Yet, it JSON-encodes into an _object_. It makes zero sense.<|eoopr|><|eols|><|endoftext|>
12
lolphp
Saltub
dompnhl
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|soopr|>We had the usual problems with filtering normal arrays requiring `array_values` to keep it from turning into an object when JSON encoding (holes in PHP's "array" turns it into a hashmap). So I looked for a more sensible array type - `SplFixedArray` - but that JSON encodes into an object _by default_ for no reason?<|eoopr|><|sor|>Just because an object has the word *array* in its name doesn't mean it's not an object. You can call objects whatever you like; it's just a name.<|eor|><|eols|><|endoftext|>
11
lolphp
corvus_192
domuv6y
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|soopr|>We had the usual problems with filtering normal arrays requiring `array_values` to keep it from turning into an object when JSON encoding (holes in PHP's "array" turns it into a hashmap). So I looked for a more sensible array type - `SplFixedArray` - but that JSON encodes into an object _by default_ for no reason?<|eoopr|><|sor|>Yes, PHP arrays are technically maps. I'm curious to hear what holes you're talking about, because in my experience it's not a common occurrence for a properly formatted JSON array to json_decode into something that isn't an array.<|eor|><|sor|>> I'm curious to hear what holes you're talking about * PHP: `[0]` -> JSON `[0]` * PHP: `[]` -> JSON `{}` This breaks things like JS array iteration<|eor|><|sor|>`[0=>7, 2=>8]` turning into `{"0": 7, "2": 8}` probably.<|eor|><|eols|><|endoftext|>
9
lolphp
prewk
domn8vk
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|soopr|>We had the usual problems with filtering normal arrays requiring `array_values` to keep it from turning into an object when JSON encoding (holes in PHP's "array" turns it into a hashmap). So I looked for a more sensible array type - `SplFixedArray` - but that JSON encodes into an object _by default_ for no reason?<|eoopr|><|eols|><|endoftext|>
8
lolphp
the_alias_of_andrea
don6oz2
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|soopr|>We had the usual problems with filtering normal arrays requiring `array_values` to keep it from turning into an object when JSON encoding (holes in PHP's "array" turns it into a hashmap). So I looked for a more sensible array type - `SplFixedArray` - but that JSON encodes into an object _by default_ for no reason?<|eoopr|><|sor|>Just because an object has the word *array* in its name doesn't mean it's not an object. You can call objects whatever you like; it's just a name.<|eor|><|soopr|>But its purpose is to provide a stricter array type, isn't it? Why does it have a well-defined behavior of JSON encoding into an object, when there's a 1:1 match with a JSON array, every time?<|eoopr|><|sor|>Most likely answer is that JsonSerializable and SplFixedArray were written by different people at different times (I think the former came later), and they didn't think to use the former on the latter. SPL is fairly neglected.<|eor|><|eols|><|endoftext|>
8
lolphp
the_alias_of_andrea
don6qwq
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|soopr|>We had the usual problems with filtering normal arrays requiring `array_values` to keep it from turning into an object when JSON encoding (holes in PHP's "array" turns it into a hashmap). So I looked for a more sensible array type - `SplFixedArray` - but that JSON encodes into an object _by default_ for no reason?<|eoopr|><|sor|>Yes, PHP arrays are technically maps. I'm curious to hear what holes you're talking about, because in my experience it's not a common occurrence for a properly formatted JSON array to json_decode into something that isn't an array.<|eor|><|soopr|>Here's an example: $stuff = ["foo", "bar", "baz"]; // json_encodes into ["foo","bar","baz"] $filtered = array_filter($stuff, function($val) { return $val[0] === "b"; }); // json_encodes into {"1":"bar","2":"baz"} $filtered = array_values($filtered); // json_encodes into ["bar","baz"] I'm fully aware that PHP arrays are maps and that they have this behavior. It's a core thing in PHP which I'm not very fond of but it's not what I'm complaining about. What I'm complaining about is that the one built-in tool that's supposed to NOT have this problem seems to be: [SplFixedArray](http://se2.php.net/manual/en/class.splfixedarray.php). `SplFixedArray` _can't_ have non-integer "keys", nor can it have non-sequential keys. Yet, it JSON-encodes into an _object_. It makes zero sense.<|eoopr|><|sor|>> SplFixedArray can't have non-integer "keys", nor can it have non-sequential keys. Yet, it JSON-encodes into an object. It's an object. So it encodes like all other objects do in PHP. Anything else would be more of a 'lol'. If you want the data inside it to encode like an array, get that array and encode that $someObject = new SplFixedArray(5); echo json_encode($someObject->toArray()); Or you can even cast it to an object: https://3v4l.org/sFG8G tbh though....the SPL is something to just avoid if at all possible.<|eor|><|sor|>> Anything else would be more of a 'lol'. No, because you can override the default behaviour by implementing `JsonSerializable`.<|eor|><|eols|><|endoftext|>
8
lolphp
Schmittfried
don4ybt
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|soopr|>We had the usual problems with filtering normal arrays requiring `array_values` to keep it from turning into an object when JSON encoding (holes in PHP's "array" turns it into a hashmap). So I looked for a more sensible array type - `SplFixedArray` - but that JSON encodes into an object _by default_ for no reason?<|eoopr|><|sor|>Yes, PHP arrays are technically maps. I'm curious to hear what holes you're talking about, because in my experience it's not a common occurrence for a properly formatted JSON array to json_decode into something that isn't an array.<|eor|><|soopr|>Here's an example: $stuff = ["foo", "bar", "baz"]; // json_encodes into ["foo","bar","baz"] $filtered = array_filter($stuff, function($val) { return $val[0] === "b"; }); // json_encodes into {"1":"bar","2":"baz"} $filtered = array_values($filtered); // json_encodes into ["bar","baz"] I'm fully aware that PHP arrays are maps and that they have this behavior. It's a core thing in PHP which I'm not very fond of but it's not what I'm complaining about. What I'm complaining about is that the one built-in tool that's supposed to NOT have this problem seems to be: [SplFixedArray](http://se2.php.net/manual/en/class.splfixedarray.php). `SplFixedArray` _can't_ have non-integer "keys", nor can it have non-sequential keys. Yet, it JSON-encodes into an _object_. It makes zero sense.<|eoopr|><|sor|>> SplFixedArray can't have non-integer "keys", nor can it have non-sequential keys. Yet, it JSON-encodes into an object. It's an object. So it encodes like all other objects do in PHP. Anything else would be more of a 'lol'. If you want the data inside it to encode like an array, get that array and encode that $someObject = new SplFixedArray(5); echo json_encode($someObject->toArray()); Or you can even cast it to an object: https://3v4l.org/sFG8G tbh though....the SPL is something to just avoid if at all possible.<|eor|><|sor|>No, it wouldnt. In object-oriented paradigms everything is an object. An array is an object, that doesnt mean it shouldnt be represented in its specific json representation. SplFixedArray emulates an array, it should behave like one everywhere. Not doing that for serialization is just stupid, period. Your distinction is arbitrary and wrong. <|eor|><|eols|><|endoftext|>
8
lolphp
Schmittfried
don52zv
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|sor|>[deleted]<|eor|><|soopr|>But it _is_ json serializable, that's not my complaint. It's what it serializes into. Do you really think it's too much to ask from a _guaranteed sequential normal array_, the only one in PHP, to actually encode into an array in JSON?<|eoopr|><|sor|>But as it doesnt implement the `JsonSerializable` interface, that means it gets serialized in the default manner all other non `JsonSerializable` objects do. Yeah, you can argue that `SplFixedArray`should implement `JsonSerializable`, but as it currently doesnt, you have to expect default object behavior.<|eor|><|sor|>Yes, but the reason why it yields incorrect results doesnt matter. If implementing JsonSerializable solves the issue, why the fuck doesnt SplFixedArray implement it? Doesnt make it any less of a lolphp. <|eor|><|eols|><|endoftext|>
7
lolphp
prewk
domwfkz
<|sols|><|sot|>PHP's only "real" array type JSON encodes into an object<|eot|><|sol|>https://3v4l.org/hYjiI<|eol|><|sor|>[deleted]<|eor|><|soopr|>But it _is_ json serializable, that's not my complaint. It's what it serializes into. Do you really think it's too much to ask from a _guaranteed sequential normal array_, the only one in PHP, to actually encode into an array in JSON?<|eoopr|><|eols|><|endoftext|>
6
lolphp
tonymyre311
47dqbf
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|eoss|><|endoftext|>
40
lolphp
ANAL_GRAVY
d0cf9me
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>Wow, it's incredibly fast searching on their site now though! I'm actually rather impressed. Seems pretty wasteful though. Nice to be aware of, but since you're letting them store it and you can change it, it's not a terrible idea; especially if it were done a bit better its quite a useful quicksearch.<|eor|><|eoss|><|endoftext|>
17
lolphp
MonkeeSage
d0d24y6
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>The search on php.net is pretty awesome now, but the JSON format they chose is just awful. There's so many duplicated and unnecessarily long strings! I'm sure they could cut the size in half with some minor optimizations.<|eor|><|sor|>> I'm sure they could cut the size in half with some minor optimizations. Look, somebody is probably depending on that undocumented, internal implementation detail. We're not going to break code just to fix an implementation.<|eor|><|eoss|><|endoftext|>
14
lolphp
DoctorWaluigiTime
d0ch992
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>At first I thought "wasteful" as well, but then, that's really a pittance in terms of storage size. I'll take it if it means fewer http requests. Not like I'm low on HDD space or anything.<|eor|><|eoss|><|endoftext|>
13
lolphp
merreborn
d0csdgm
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>At first I thought "wasteful" as well, but then, that's really a pittance in terms of storage size. I'll take it if it means fewer http requests. Not like I'm low on HDD space or anything.<|eor|><|sor|>> that's really a pittance in terms of storage size It's fine on a full-blown desktop. It's pretty bloated on a mobile device, though. Especially low-end burner-phone type devices.<|eor|><|eoss|><|endoftext|>
12
lolphp
the_alias_of_andrea
d0c61vb
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>Well, you can refuse to let php.net use localStorage if it bothers you. The duplication across domains is unfortunate, but I guess it's an inevitability of the donated mirror system php.net uses. Which we can't do much about.<|eor|><|eoss|><|endoftext|>
11
lolphp
phoshi
d0ckcbu
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>it's almost like browsers have this problem solved for 20 years with something called "caching" it works like magic, any files you download are kept in local storage and when you use those files often they'll remain there you can even set http headers on your response telling it for how long and how often to check it's updated and all that without subverting other mechanisms!<|eor|><|sor|>Caching is meant to be transparent to the application, because it's the client's choice whether they ignore or accept the suggestion. A client silently ignoring your cache instruction is perfectly valid, and there's no way for you to know about it, and you really really don't want to serve out 2mb of json for every hit to your autocomplete. <|eor|><|eoss|><|endoftext|>
11
lolphp
the_pw_is_in_this_ID
d0cuxvs
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>At first I thought "wasteful" as well, but then, that's really a pittance in terms of storage size. I'll take it if it means fewer http requests. Not like I'm low on HDD space or anything.<|eor|><|sor|>> that's really a pittance in terms of storage size It's fine on a full-blown desktop. It's pretty bloated on a mobile device, though. Especially low-end burner-phone type devices.<|eor|><|sor|>And that's why you'd configure local storage accordingly for your mobile devices.<|eor|><|sor|>Good luck with that configuration on devices you can't root :(<|eor|><|eoss|><|endoftext|>
8
lolphp
headzoo
d0d11go
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>The search on php.net is pretty awesome now, but the JSON format they chose is just awful. There's so many duplicated and unnecessarily long strings! I'm sure they could cut the size in half with some minor optimizations.<|eor|><|eoss|><|endoftext|>
6
lolphp
Matt3k
d0dbs51
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>it's almost like browsers have this problem solved for 20 years with something called "caching" it works like magic, any files you download are kept in local storage and when you use those files often they'll remain there you can even set http headers on your response telling it for how long and how often to check it's updated and all that without subverting other mechanisms!<|eor|><|sor|>Caching is meant to be transparent to the application, because it's the client's choice whether they ignore or accept the suggestion. A client silently ignoring your cache instruction is perfectly valid, and there's no way for you to know about it, and you really really don't want to serve out 2mb of json for every hit to your autocomplete. <|eor|><|sor|>2mb of static json, gzip compressed, with a reasonable HTTP cache expiration is absolutely the correct solution here. HTTP caches clean themselves up according to LRU and expiration rules, are well understood, and the user interfaces for managing it are known. This is preferable to having MBs of storage occupied on a client's browser until the end of time. Sites serve up hundreds of MB of images and enormous javascript libraries all the time and no one is crying about someone having their cache disabled. That is part of running a website. Finally, if this really stresses the owners of php.net so much, then *don't try to cache the entire dataset in the first place*. Autocomplete any entry 3 characters or longer and use a database lookup. Like most other serious autocomplete widgets. What if we had 50MB of data to search. Or a GB of data to search. Would you still stick it in a JSON file on the user's computer? Of course not. <|eor|><|eoss|><|endoftext|>
6
lolphp
phoshi
d0cmwxd
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>it's almost like browsers have this problem solved for 20 years with something called "caching" it works like magic, any files you download are kept in local storage and when you use those files often they'll remain there you can even set http headers on your response telling it for how long and how often to check it's updated and all that without subverting other mechanisms!<|eor|><|sor|>Caching is meant to be transparent to the application, because it's the client's choice whether they ignore or accept the suggestion. A client silently ignoring your cache instruction is perfectly valid, and there's no way for you to know about it, and you really really don't want to serve out 2mb of json for every hit to your autocomplete. <|eor|><|sor|>> it's the client's choice whether they ignore or accept the suggestion that point also applies to client side storage > there's no way for you to know about it actually i'm quite sure there is > you really really don't want to serve out 2mb of json for every hit to your autocomplete. well there's your problem -- shitty application design and it wouldn't be for "every hit to your autocomplete", it would be for every page with a search box that loads fresh assuming no other similar pages are already open (thus keeping the relevant file in memory) and the browser doesn't decide to keep the file in disk because it's used so much lastly, 2mb is an absolutely trivial amount, any person frequenting, for example, a gaming forum will have hundreds of megabytes of animated sigs, avatars, etc on his browser cache that absolutely don't get downloaded for every new forum page the user opens and finally, most web applications that rely on a lot of javascript load them from static js files that get cached just like that, often many times that size<|eor|><|sor|>Client side storage has far more robust methods of telling whether the client will let you use it or not. Cache really isn't something you can rely on to always play by the same rules, whereas local storage actually has strong definitions on how it behaves. Local storage is absolutely what this kind of information should be stored with. You just can't rely on browser caches. For all you know, the browser could have enough other things cached with a high enough priority that your 2mb of json gets pushed out of the cache within seconds, meaning that you've probably just doubled your page weight on systems that are already resource constrained--and /that/ would be a lolphp. Using local storage to store local data isn't inherently so. <|eor|><|eoss|><|endoftext|>
6
lolphp
the_alias_of_andrea
d0d34qq
<|soss|><|sot|>Meta-example: php.net local storage<|eot|><|sost|>I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains). Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc. It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution. Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX **Edit:** For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!<|eost|><|sor|>it's almost like browsers have this problem solved for 20 years with something called "caching" it works like magic, any files you download are kept in local storage and when you use those files often they'll remain there you can even set http headers on your response telling it for how long and how often to check it's updated and all that without subverting other mechanisms!<|eor|><|sor|>Caching is meant to be transparent to the application, because it's the client's choice whether they ignore or accept the suggestion. A client silently ignoring your cache instruction is perfectly valid, and there's no way for you to know about it, and you really really don't want to serve out 2mb of json for every hit to your autocomplete. <|eor|><|sor|>> it's the client's choice whether they ignore or accept the suggestion that point also applies to client side storage > there's no way for you to know about it actually i'm quite sure there is > you really really don't want to serve out 2mb of json for every hit to your autocomplete. well there's your problem -- shitty application design and it wouldn't be for "every hit to your autocomplete", it would be for every page with a search box that loads fresh assuming no other similar pages are already open (thus keeping the relevant file in memory) and the browser doesn't decide to keep the file in disk because it's used so much lastly, 2mb is an absolutely trivial amount, any person frequenting, for example, a gaming forum will have hundreds of megabytes of animated sigs, avatars, etc on his browser cache that absolutely don't get downloaded for every new forum page the user opens and finally, most web applications that rely on a lot of javascript load them from static js files that get cached just like that, often many times that size<|eor|><|sor|>Client side storage has far more robust methods of telling whether the client will let you use it or not. Cache really isn't something you can rely on to always play by the same rules, whereas local storage actually has strong definitions on how it behaves. Local storage is absolutely what this kind of information should be stored with. You just can't rely on browser caches. For all you know, the browser could have enough other things cached with a high enough priority that your 2mb of json gets pushed out of the cache within seconds, meaning that you've probably just doubled your page weight on systems that are already resource constrained--and /that/ would be a lolphp. Using local storage to store local data isn't inherently so. <|eor|><|sor|>Especially if it's a large item, the browser often refuses to cache something. I find that [win95.ajf.me](https://win95.ajf.me/)'s disk image rarely gets cached.<|eor|><|eoss|><|endoftext|>
5
lolphp
cbraga
45iyo6
<|sols|><|sot|>"phpversions.info now highlights PHP versions with known security issues", they could've saved themselves the effort and just painted everything red though<|eot|><|sol|>http://phpversions.info/shared-hosting/<|eol|><|eols|><|endoftext|>
39