subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
postmodest
cma27c3
<|sols|><|sot|>When a PHP dev creates a troll issue for HHVM...<|eot|><|sol|>https://github.com/facebook/hhvm/issues/4290<|eol|><|sor|>> PHP programmers have got used to T_PAAMAYIM_NEKUDOTAYIM. Are you fuckin serious? Why in the blithering fuck are you defending mixing in random goddamn hebrew-named variables? edit: ugh. http://www.reddit.com/r/PHP/comments/1m26z1/t_paamayim_nekudotayim_v_sanity/<|eor|><|sor|>Always loved that excuse. "Oh, a multi-lingual translation got put into the wrong language? It's a nod to our fellow [country]!"<|eor|><|sor|>I'm gonna make my own interpreted language! With Klingon, and Hookers!<|eor|><|eols|><|endoftext|>
11
lolphp
DoctorWaluigiTime
cm9zkfo
<|sols|><|sot|>When a PHP dev creates a troll issue for HHVM...<|eot|><|sol|>https://github.com/facebook/hhvm/issues/4290<|eol|><|sor|>> PHP programmers have got used to T_PAAMAYIM_NEKUDOTAYIM. Are you fuckin serious? Why in the blithering fuck are you defending mixing in random goddamn hebrew-named variables? edit: ugh. http://www.reddit.com/r/PHP/comments/1m26z1/t_paamayim_nekudotayim_v_sanity/<|eor|><|sor|>Always loved that excuse. "Oh, a multi-lingual translation got put into the wrong language? It's a nod to our fellow [country]!"<|eor|><|eols|><|endoftext|>
9
lolphp
sloat
cma3mpj
<|sols|><|sot|>When a PHP dev creates a troll issue for HHVM...<|eot|><|sol|>https://github.com/facebook/hhvm/issues/4290<|eol|><|sor|>> PHP programmers have got used to T_PAAMAYIM_NEKUDOTAYIM. Are you fuckin serious? Why in the blithering fuck are you defending mixing in random goddamn hebrew-named variables? edit: ugh. http://www.reddit.com/r/PHP/comments/1m26z1/t_paamayim_nekudotayim_v_sanity/<|eor|><|soopr|>> Are you fuckin serious? No. "troll issue".<|eoopr|><|sor|>Led to actual bug report on PHP's tracker: [https://bugs.php.net/bug.php?id=68467](https://bugs.php.net/bug.php?id=68467) Not sure if that one is a trollback... <|eor|><|eols|><|endoftext|>
9
lolphp
nsfwIvan
cma44s2
<|sols|><|sot|>When a PHP dev creates a troll issue for HHVM...<|eot|><|sol|>https://github.com/facebook/hhvm/issues/4290<|eol|><|sor|>> PHP programmers have got used to T_PAAMAYIM_NEKUDOTAYIM. Are you fuckin serious? Why in the blithering fuck are you defending mixing in random goddamn hebrew-named variables? edit: ugh. http://www.reddit.com/r/PHP/comments/1m26z1/t_paamayim_nekudotayim_v_sanity/<|eor|><|sor|>Always loved that excuse. "Oh, a multi-lingual translation got put into the wrong language? It's a nod to our fellow [country]!"<|eor|><|sor|>I'm gonna make my own interpreted language! With Klingon, and Hookers!<|eor|><|sor|>I like the hookers part. When can we see a prototype?<|eor|><|eols|><|endoftext|>
7
lolphp
Banane9
cmbhe53
<|sols|><|sot|>When a PHP dev creates a troll issue for HHVM...<|eot|><|sol|>https://github.com/facebook/hhvm/issues/4290<|eol|><|sor|>> PHP programmers have got used to T_PAAMAYIM_NEKUDOTAYIM. Are you fuckin serious? Why in the blithering fuck are you defending mixing in random goddamn hebrew-named variables? edit: ugh. http://www.reddit.com/r/PHP/comments/1m26z1/t_paamayim_nekudotayim_v_sanity/<|eor|><|soopr|>> Are you fuckin serious? No. "troll issue".<|eoopr|><|sor|>Led to actual bug report on PHP's tracker: [https://bugs.php.net/bug.php?id=68467](https://bugs.php.net/bug.php?id=68467) Not sure if that one is a trollback... <|eor|><|sor|>I'm surprised they haven't *won't fix*ed it yet<|eor|><|eols|><|endoftext|>
5
lolphp
ealf
2d6kll
<|sols|><|sot|>"The PHP session code explicitly checks for symlinks [...] It does this by opening the file, then doing fstat() on the open file descriptor"<|eot|><|sol|>http://seclists.org/bugtraq/2014/Mar/23<|eol|><|eols|><|endoftext|>
60
lolphp
redfacedquark
cjnbr7q
<|sols|><|sot|>"The PHP session code explicitly checks for symlinks [...] It does this by opening the file, then doing fstat() on the open file descriptor"<|eot|><|sol|>http://seclists.org/bugtraq/2014/Mar/23<|eol|><|sor|>Tumbleweed...let me take a stab at it. By the time it opens the file it has already followed the symlink to the target file?<|eor|><|eols|><|endoftext|>
14
lolphp
shitbangs
cjnxjad
<|sols|><|sot|>"The PHP session code explicitly checks for symlinks [...] It does this by opening the file, then doing fstat() on the open file descriptor"<|eot|><|sol|>http://seclists.org/bugtraq/2014/Mar/23<|eol|><|sor|>Tumbleweed...let me take a stab at it. By the time it opens the file it has already followed the symlink to the target file?<|eor|><|sor|>Yes, fstat works on a file descriptor, and it's impossible to open a file descriptor to a symlink. Either you follow the symlink and open the target (which PHP does), or you declare that you don't want to follow symlinks (O_NOFOLLOW), in which case an open() on a symlink fails. Edit: Apparently nowadays there's a flag for that.<|eor|><|sor|>Actually, `O_PATH | O_NOFOLLOW` lets one open a file descriptor to a symlink.<|eor|><|sor|>Kids these days with their fancy flags.<|eor|><|sor|>More like kids these days with their [non-portable](http://www.freebsd.org/cgi/man.cgi?query=open&apropos=0&sektion=2&manpath=FreeBSD+11-current&arch=default&format=html) [system](https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man2/open.2.html) [calls](http://smartos.org/man/2/open)<|eor|><|eols|><|endoftext|>
10
lolphp
suspiciously_calm
cjnwbgk
<|sols|><|sot|>"The PHP session code explicitly checks for symlinks [...] It does this by opening the file, then doing fstat() on the open file descriptor"<|eot|><|sol|>http://seclists.org/bugtraq/2014/Mar/23<|eol|><|sor|>Tumbleweed...let me take a stab at it. By the time it opens the file it has already followed the symlink to the target file?<|eor|><|sor|>Yes, fstat works on a file descriptor, and it's impossible to open a file descriptor to a symlink. Either you follow the symlink and open the target (which PHP does), or you declare that you don't want to follow symlinks (O_NOFOLLOW), in which case an open() on a symlink fails. Edit: Apparently nowadays there's a flag for that.<|eor|><|sor|>Actually, `O_PATH | O_NOFOLLOW` lets one open a file descriptor to a symlink.<|eor|><|sor|>Kids these days with their fancy flags.<|eor|><|eols|><|endoftext|>
9
lolphp
suspiciously_calm
cjnhd8t
<|sols|><|sot|>"The PHP session code explicitly checks for symlinks [...] It does this by opening the file, then doing fstat() on the open file descriptor"<|eot|><|sol|>http://seclists.org/bugtraq/2014/Mar/23<|eol|><|sor|>Tumbleweed...let me take a stab at it. By the time it opens the file it has already followed the symlink to the target file?<|eor|><|sor|>Yes, fstat works on a file descriptor, and it's impossible to open a file descriptor to a symlink. Either you follow the symlink and open the target (which PHP does), or you declare that you don't want to follow symlinks (O_NOFOLLOW), in which case an open() on a symlink fails. Edit: Apparently nowadays there's a flag for that.<|eor|><|eols|><|endoftext|>
8
lolphp
sstewartgallus
cjnvdng
<|sols|><|sot|>"The PHP session code explicitly checks for symlinks [...] It does this by opening the file, then doing fstat() on the open file descriptor"<|eot|><|sol|>http://seclists.org/bugtraq/2014/Mar/23<|eol|><|sor|>Tumbleweed...let me take a stab at it. By the time it opens the file it has already followed the symlink to the target file?<|eor|><|sor|>Yes, fstat works on a file descriptor, and it's impossible to open a file descriptor to a symlink. Either you follow the symlink and open the target (which PHP does), or you declare that you don't want to follow symlinks (O_NOFOLLOW), in which case an open() on a symlink fails. Edit: Apparently nowadays there's a flag for that.<|eor|><|sor|>Actually, `O_PATH | O_NOFOLLOW` lets one open a file descriptor to a symlink.<|eor|><|eols|><|endoftext|>
5
lolphp
TimLim
2094sd
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|eols|><|endoftext|>
65
lolphp
suspiciously_calm
cg10fvw
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>PHP runtime error handling: Barf something out on STDERR **but continue.**<|eor|><|eols|><|endoftext|>
41
lolphp
Benutzername
cg0zx9h
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>I couldn't convert it to int, but what the heck, I'm generous today!<|eor|><|eols|><|endoftext|>
37
lolphp
lisp-case
cg10qcr
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>PHP runtime error handling: Barf something out on STDERR **but continue.**<|eor|><|sor|>I especially like how the default behavior of a failed `assert` is to do exactly this.<|eor|><|eols|><|endoftext|>
29
lolphp
lisp-case
cg13jbu
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>*sigh I still love this one the most though. $x->something = 'blah'; var_dump($x) Warning: Creating default object from empty value in test.php on line 2 object(stdClass)#1 (1) { ["something"]=> string(4) "blah" } It's when you're on the go and quickly need to create a stdClass. Also works with `$x=null` and the `$x=''`, but not with `0`, `'0'` or `array()`, because they are not `empty()`, oh wait...<|eor|><|sor|>You're joking. $ php -a Interactive shell php > $x = 0; php > $x->something = 'blah'; PHP Warning: Attempt to assign property of non-object in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 php > var_dump($x); int(0) php > $x = ''; php > $x->something = 'blah'; PHP Warning: Creating default object from empty value in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 php > var_dump($x); class stdClass#1 (1) { public $something => string(4) "blah" } php > Nope, you're not. Wow. I've said this before, but every time I think I've mined it out, PHP offers up another lode of WTF.<|eor|><|eols|><|endoftext|>
28
lolphp
nstory
cg170gx
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>PHP runtime error handling: Barf something out on STDERR **but continue.**<|eor|><|sor|>Actually, the standard behavior is to [barf that something out on STDOUT](http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors). SIGH. <|eor|><|eols|><|endoftext|>
25
lolphp
andsens
cg12wpm
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>*sigh I still love this one the most though. $x->something = 'blah'; var_dump($x) Warning: Creating default object from empty value in test.php on line 2 object(stdClass)#1 (1) { ["something"]=> string(4) "blah" } It's when you're on the go and quickly need to create a stdClass. Also works with `$x=null` and the `$x=''`, but not with `0`, `'0'` or `array()`, because they are not `empty()`, oh wait...<|eor|><|eols|><|endoftext|>
21
lolphp
quchen
cg10dfi
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>And you highlight why E_ALL is what every PHP programmer should be developing in.<|eor|><|sor|>Which, until 5.4, included *all* warnings. [Except the ones it didn't.](http://www.php.net/manual/en/function.error-reporting.php#refsect1-function.error-reporting-changelog)<|eor|><|eols|><|endoftext|>
20
lolphp
vita10gy
cg16a1a
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>PHP runtime error handling: Barf something out on STDERR **but continue.**<|eor|><|sor|>That's PHP SOP. Something nonsensical is always better than nothing. Stopping is the world's greatest sin. <|eor|><|eols|><|endoftext|>
19
lolphp
mayobutter
cg1a6qv
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>PHP runtime error handling: Barf something out on STDERR **but continue.**<|eor|><|sor|>That's PHP SOP. Something nonsensical is always better than nothing. Stopping is the world's greatest sin. <|eor|><|sor|>Unless you forget a goddamn semicolon.<|eor|><|eols|><|endoftext|>
19
lolphp
ajmarks
cg14aa5
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>Doesn't seem that bad. Maybe the value of 1 is used so you can do `if (object) do stuff;`. In my mind, doing something as illogical as this should return an error. <|eor|><|sor|>In a normal language, it would be possible to make object() truthy without being an int.<|eor|><|eols|><|endoftext|>
12
lolphp
DoctorWaluigiTime
cg0zoid
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>And you highlight why E_ALL is what every PHP programmer should be developing in.<|eor|><|eols|><|endoftext|>
10
lolphp
mirhagk
cg7xma0
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>*sigh I still love this one the most though. $x->something = 'blah'; var_dump($x) Warning: Creating default object from empty value in test.php on line 2 object(stdClass)#1 (1) { ["something"]=> string(4) "blah" } It's when you're on the go and quickly need to create a stdClass. Also works with `$x=null` and the `$x=''`, but not with `0`, `'0'` or `array()`, because they are not `empty()`, oh wait...<|eor|><|sor|>You're joking. $ php -a Interactive shell php > $x = 0; php > $x->something = 'blah'; PHP Warning: Attempt to assign property of non-object in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 php > var_dump($x); int(0) php > $x = ''; php > $x->something = 'blah'; PHP Warning: Creating default object from empty value in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 php > var_dump($x); class stdClass#1 (1) { public $something => string(4) "blah" } php > Nope, you're not. Wow. I've said this before, but every time I think I've mined it out, PHP offers up another lode of WTF.<|eor|><|sor|>> I've said this before, but every time I think I've mined it out, PHP offers up another lode of WTF. I know. I keep coming back to this subreddit and expecting it to be deserted because we've found all the WTF of PHP. But nope. Still more. Always.<|eor|><|eols|><|endoftext|>
8
lolphp
nahguri
cg1oagb
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>PHP runtime error handling: Barf something out on STDERR **but continue.**<|eor|><|sor|>The show must go on!<|eor|><|eols|><|endoftext|>
7
lolphp
kingguru
cg2btpt
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>PHP runtime error handling: Barf something out on STDERR **but continue.**<|eor|><|sor|>That's PHP SOP. Something nonsensical is always better than nothing. Stopping is the world's greatest sin. <|eor|><|sor|>Unless you forget a goddamn semicolon.<|eor|><|sor|>That's one of the reasons JavaScript is such a wonderful language. It is helpful enough to insert semicolons in your code in places where the interpreter thinks you might have forgotten them. I cannot imagine any situations where that could be a problem. /sarcasm<|eor|><|eols|><|endoftext|>
7
lolphp
freebullets
cg10cfv
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>Doesn't seem that bad. Maybe the value of 1 is used so you can do `if (object) do stuff;`. In my mind, doing something as illogical as this should return an error. <|eor|><|eols|><|endoftext|>
5
lolphp
bart2019
cg1j12m
<|sols|><|sot|>new object() + new object() == 2<|eot|><|sol|>http://codepad.org/NGPjR4fl<|eol|><|sor|>PHP runtime error handling: Barf something out on STDERR **but continue.**<|eor|><|sor|>Yet a redefinition of a function is a fatal error.<|eor|><|eols|><|endoftext|>
5
lolphp
sandsmark
1ofw7t
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|eols|><|endoftext|>
63
lolphp
catcradle5
ccrlbja
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|eols|><|endoftext|>
42
lolphp
InconsiderateBastard
ccrmdap
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|sor|>I hate that I know why it does that. Not because I hate the knowledge, but I hate that I had to acquire the knowledge.<|eor|><|eols|><|endoftext|>
23
lolphp
suspiciously_calm
ccrncto
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|sor|>What the actual fuck. How would this ever be useful? It's not a reliable way to obtain the lexicographic successor of a string, nor is it consistent with the "strings are equal to the numbers they represent" narrative (by which "2d9" == 2).<|eor|><|eols|><|endoftext|>
13
lolphp
sandsmark
ccrkmld
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|eols|><|endoftext|>
12
lolphp
barubary
ccsqig3
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|sor|>What the actual fuck. How would this ever be useful? It's not a reliable way to obtain the lexicographic successor of a string, nor is it consistent with the "strings are equal to the numbers they represent" narrative (by which "2d9" == 2).<|eor|><|sor|>PHP claims it's behavior borrowed from Perl. Testing it in Perl, though, seems to show that if the string begins with one or more digits, it coerces to just those digits and then increments.<|eor|><|sor|>Like many things in PHP it was originally taken from Perl without understanding what Perl actually does and why, and thus completely messed up in PHP. In Perl, the magic version of increment kicks in if the string * has never been used as a number * is non-empty * matches the regex `\A[A-Za-z]*[0-9]*\z` This means it never applies to anything that looks like a hex (`0x...`) or scientific (`123e...`) literal. As to what it's useful for: ranges, mainly. for my $i ('000' .. '999') { say $i; } # 000, 001, 002, ... for my $i ('AA' .. 'ZZ') { say $i; } # AA, AB, AC, ... and of course the popular my @chars = ('_', '0' .. '9', 'a' .. 'z', 'A' .. 'Z');<|eor|><|eols|><|endoftext|>
12
lolphp
vytah
ccs1dur
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|sor|>What the actual fuck. How would this ever be useful? It's not a reliable way to obtain the lexicographic successor of a string, nor is it consistent with the "strings are equal to the numbers they represent" narrative (by which "2d9" == 2).<|eor|><|sor|>You can use it to iterate from AAA000 to ZZZ999.<|eor|><|eols|><|endoftext|>
7
lolphp
suspiciously_calm
ccxu4n0
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|sor|>What the actual fuck. How would this ever be useful? It's not a reliable way to obtain the lexicographic successor of a string, nor is it consistent with the "strings are equal to the numbers they represent" narrative (by which "2d9" == 2).<|eor|><|sor|>It is useful. Even ruby has a special function for it, '2d9'.next returns '2e0'<|eor|><|sor|>Yes, in Ruby it's useful, because '2e0'.next returns '2e1', not 3.<|eor|><|eols|><|endoftext|>
7
lolphp
sandsmark
ccrlnsl
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|soopr|>> In this case, it looks like it interprets "2d9" as a string containing a hex number, which when incremented would then be "2e0" in hex. No, it would be 2da, which is what makes this so mind-boggling.<|eoopr|><|sor|>I edited my comment. I mixed up some of my words in the first rendition. When the string is just "2d9", it treats it the same way it would treat the string "ihasdygasdijasd97234jknsdf". Incrementing such a string will first increment the last "f" to "g", and then when it hits "z" the last character will wrap around and the preceding character is incremented, so the last 2 characters would be "ea" after the following increment. It only thinks the string is hex if it begins with "0x" or "0X".<|eor|><|soopr|>yup, I can see how it works, but it makes absolutely no sense. That's php for you.<|eoopr|><|eols|><|endoftext|>
7
lolphp
catcradle5
ccrloen
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|soopr|>> In this case, it looks like it interprets "2d9" as a string containing a hex number, which when incremented would then be "2e0" in hex. No, it would be 2da, which is what makes this so mind-boggling.<|eoopr|><|sor|>I edited my comment. I mixed up some of my words in the first rendition. When the string is just "2d9", it treats it the same way it would treat the string "ihasdygasdijasd97234jknsdf". Incrementing such a string will first increment the last "f" to "g", and then when it hits "z" the last character will wrap around and the preceding character is incremented, so the last 2 characters would be "ea" after the following increment. It only thinks the string is hex if it begins with "0x" or "0X".<|eor|><|soopr|>yup, I can see how it works, but it makes absolutely no sense. That's php for you.<|eoopr|><|sor|>Yep. Par for the course, I'm afraid.<|eor|><|eols|><|endoftext|>
7
lolphp
sandsmark
ccrlgqk
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|soopr|>> In this case, it looks like it interprets "2d9" as a string containing a hex number, which when incremented would then be "2e0" in hex. No, it would be 2da, which is what makes this so mind-boggling.<|eoopr|><|eols|><|endoftext|>
6
lolphp
ajmarks
ccsdidd
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|sor|>Yeah making $a++ and $a+=1 not more or less equivalent is a huge fail. Also, fun with hex: https://eval.in/54634.<|eor|><|eols|><|endoftext|>
5
lolphp
suspiciously_calm
ccs0tuj
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|sor|>What the actual fuck. How would this ever be useful? It's not a reliable way to obtain the lexicographic successor of a string, nor is it consistent with the "strings are equal to the numbers they represent" narrative (by which "2d9" == 2).<|eor|><|sor|>Serial numbers or ids and such.<|eor|><|sor|>It works for ids in some formats, but not others (ids with a suffix, such as file extensions, ids with hexadecimal counters, ids with a prefix that could be incremented to a number representation, as OP shows, ...) It targets a relatively narrow scope, but infects a basic operator with unexpected behavior in the process. It breaks one of PHP's own fundamental concepts, that is, weak typing, by which you would expect the ++ operator to coerce its argument to a numeric type.<|eor|><|eols|><|endoftext|>
5
lolphp
vytah
cd8ubwf
<|sols|><|sot|>2d9<|eot|><|sol|>http://ideone.com/l6aQSx<|eol|><|soopr|>so, can anyone explain why 2d9 + 1 == 2e0?<|eoopr|><|sor|>`$a++` does something quite different from `$a = $a + 1` php > $a = "2d9"; php > echo $a."\n"; 2d9 php > echo ($a + 1)."\n"; 3 php > $a++; php > echo $a."\n"; 2e0 php > $b = "B"; php > $b++; php > echo $b."\n"; C php > echo ($b + 1)."\n; 1 `++` will increase the right-most ASCII ordinal by one if the operand is a string *whether it appears to contain a representation of a valid integer or not*. If the string is entirely base-10 digits, it seems equivalent to ` + 1`. ` + 1` always tries to do plain integer adding. `++` does the ASCII incrementing with a range of "A-Za-z0-9", so that you could manipulate alphanumeric ranges for example. However, from what I can tell there are some "is this a valid integer, or just a general alphanumeric string?" special case checks when incrementing with `++` looks at a few other things. In this case, it looks like it interprets `"2d9"` as an ordinary string not representing a number, which when incremented would then be `"2e0"` (like how `"GGGL9"` would be `"GGGM0"` when incremented, naturally!!). However, the next time it increments, before falling through to "ok, this is just a string" it has an "is it engineering notation?" branch and sees the `NUMeNUM` as engineering notation. Now it no longer sees it as a character string, even though it thought so before the current increment. It currently thinks it's a string representing a number in engineering notation (`2e0`, or `2`). It's an utter mess. tl;dr Multi-purpose incrementing with the same operator + weak typing = vomit<|eor|><|soopr|>> In this case, it looks like it interprets "2d9" as a string containing a hex number, which when incremented would then be "2e0" in hex. No, it would be 2da, which is what makes this so mind-boggling.<|eoopr|><|sor|>I edited my comment. I mixed up some of my words in the first rendition. When the string is just "2d9", it treats it the same way it would treat the string "ihasdygasdijasd97234jknsdf". Incrementing such a string will first increment the last "f" to "g", and then when it hits "z" the last character will wrap around and the preceding character is incremented, so the last 2 characters would be "ea" after the following increment. It only thinks the string is hex if it begins with "0x" or "0X".<|eor|><|sor|> $a = '0wzz'; $a++; // $a is now '0xaa' $a++; // $a is now 171<|eor|><|eols|><|endoftext|>
5
lolphp
notR1CH
1m0vfu
<|sols|><|sot|>PHP documentation suggests using header injection via ini_set() to add HTTP headers<|eot|><|sol|>http://www.php.net/manual/en/wrappers.http.php#wrappers.http.example.custom.headers<|eol|><|eols|><|endoftext|>
61
lolphp
jmcs
cc4qc9r
<|sols|><|sot|>PHP documentation suggests using header injection via ini_set() to add HTTP headers<|eot|><|sol|>http://www.php.net/manual/en/wrappers.http.php#wrappers.http.example.custom.headers<|eol|><|sor|>I don't think it suggests it, more mentions that it's possible. The page says: "it is also possible to use this **hack**" (emphasis mine).<|eor|><|sor|>That's probably something that should never be documented.<|eor|><|eols|><|endoftext|>
24
lolphp
pgl
cc4q3pk
<|sols|><|sot|>PHP documentation suggests using header injection via ini_set() to add HTTP headers<|eot|><|sol|>http://www.php.net/manual/en/wrappers.http.php#wrappers.http.example.custom.headers<|eol|><|sor|>I don't think it suggests it, more mentions that it's possible. The page says: "it is also possible to use this **hack**" (emphasis mine).<|eor|><|eols|><|endoftext|>
13
lolphp
jmcs
cc4rc06
<|sols|><|sot|>PHP documentation suggests using header injection via ini_set() to add HTTP headers<|eot|><|sol|>http://www.php.net/manual/en/wrappers.http.php#wrappers.http.example.custom.headers<|eol|><|sor|>I don't think it suggests it, more mentions that it's possible. The page says: "it is also possible to use this **hack**" (emphasis mine).<|eor|><|sor|>That's probably something that should never be documented.<|eor|><|sor|>Except, people are going to figure it out anyway, and then it would be just an undocumented hack that someone would add as a comment. *Then* I'd say it was a lolphp...<|eor|><|sor|>Hacks like this shouldn't be documented except when preceded by a warning saying that if you do this you should be raped by a bear, shot on the face, torched on fire and dumped on the nearest sewer, not necessarily by this order, in the way the disclaimer is written right now it seems it's sort of ok to do this.<|eor|><|eols|><|endoftext|>
12
lolphp
Andryu67
cc4qop5
<|sols|><|sot|>PHP documentation suggests using header injection via ini_set() to add HTTP headers<|eot|><|sol|>http://www.php.net/manual/en/wrappers.http.php#wrappers.http.example.custom.headers<|eol|><|sor|>Wow... What's next, a helpful hint on adding \0 to file names? <|eor|><|eols|><|endoftext|>
10
lolphp
Matt3k
cc4t1xu
<|sols|><|sot|>PHP documentation suggests using header injection via ini_set() to add HTTP headers<|eot|><|sol|>http://www.php.net/manual/en/wrappers.http.php#wrappers.http.example.custom.headers<|eol|><|sor|>I don't think it suggests it, more mentions that it's possible. The page says: "it is also possible to use this **hack**" (emphasis mine).<|eor|><|sor|>You can make a strong argument that this functionality shouldn't be possible. There already exist mechanisms for adding an HTTP header, and if CRLF is a disallowed value that introduces side effects beyond 'setting an HTTP header', then the framework should be filtering it. When the input comes from the user, this sort of thing is called a response splitting vulnerability. <|eor|><|eols|><|endoftext|>
6
lolphp
pgl
cc4r6ip
<|sols|><|sot|>PHP documentation suggests using header injection via ini_set() to add HTTP headers<|eot|><|sol|>http://www.php.net/manual/en/wrappers.http.php#wrappers.http.example.custom.headers<|eol|><|sor|>I don't think it suggests it, more mentions that it's possible. The page says: "it is also possible to use this **hack**" (emphasis mine).<|eor|><|sor|>That's probably something that should never be documented.<|eor|><|sor|>Except, people are going to figure it out anyway, and then it would be just an undocumented hack that someone would add as a comment. *Then* I'd say it was a lolphp...<|eor|><|eols|><|endoftext|>
6
lolphp
Pixa
cc5dwux
<|sols|><|sot|>PHP documentation suggests using header injection via ini_set() to add HTTP headers<|eot|><|sol|>http://www.php.net/manual/en/wrappers.http.php#wrappers.http.example.custom.headers<|eol|><|sor|>lol, this is stupid. On a side note: why are usernames hidden on this subreddit? You do realize that its not really hidden at all...?<|eor|><|sor|>[See here](http://www.reddit.com/r/lolphp/comments/1h8yow/meta_why_do_the_custom_styles_on_this_subreddit/)<|eor|><|sor|>Well that solved nothing.<|eor|><|sor|>Done in true PHP style.<|eor|><|eols|><|endoftext|>
6
lolphp
Takeoded
ebgewe
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|eols|><|endoftext|>
64
lolphp
BufferUnderpants
fb5a4uz
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|sor|>Hey man they had to rush to push it to the market, else they were going to lose the big bucks that people pay them for each PHP release. We've all been there.<|eor|><|eols|><|endoftext|>
12
lolphp
postmodest
fb6dnoa
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|sor|>Would adding them both for consistency sake be better?<|eor|><|soopr|>Yes. (actually im just grumpy because a FILTER\_VALIDATE\_BOOL caused a syntax error in my code while the FILTER\_VALIDATE\_INT next to it didn't, then i had to friggin look it up in the docs and.. yeah, grumpy)<|eoopr|><|sor|>Can you link your PR?<|eor|><|sor|>If there were a PR for every LOLPHP, the Internet would crash.<|eor|><|eols|><|endoftext|>
12
lolphp
Takeoded
fb63ac0
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|sor|>Would adding them both for consistency sake be better?<|eor|><|soopr|>Yes. (actually im just grumpy because a FILTER\_VALIDATE\_BOOL caused a syntax error in my code while the FILTER\_VALIDATE\_INT next to it didn't, then i had to friggin look it up in the docs and.. yeah, grumpy)<|eoopr|><|eols|><|endoftext|>
9
lolphp
cowboyecosse
fb66luc
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|sor|>Hey man they had to rush to push it to the market, else they were going to lose the big bucks that people pay them for each PHP release. We've all been there.<|eor|><|sor|>Not a reason to be sloppy. PHP is an infinite "testing on production"<|eor|><|sor|>Nah its an infinite, cant implement because backwards incompatibility<|eor|><|eols|><|endoftext|>
9
lolphp
bitfxxker
fb7ledh
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|sor|>**FILTER\_VALIDATE\_BOOLSHIT**<|eor|><|eols|><|endoftext|>
7
lolphp
walterbanana
fck03sg
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|sor|>My fix for this has now been merged: https://github.com/php/php-src/commit/f13d0a72d5cf92785c91ffc33c27df3df3f8e96e<|eor|><|eols|><|endoftext|>
6
lolphp
walterbanana
fb610h7
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|sor|>Would adding them both for consistency sake be better?<|eor|><|eols|><|endoftext|>
5
lolphp
walterbanana
fb70ghe
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|sor|>Would adding them both for consistency sake be better?<|eor|><|soopr|>Yes. (actually im just grumpy because a FILTER\_VALIDATE\_BOOL caused a syntax error in my code while the FILTER\_VALIDATE\_INT next to it didn't, then i had to friggin look it up in the docs and.. yeah, grumpy)<|eoopr|><|sor|>Can you link your PR?<|eor|><|sor|>If there were a PR for every LOLPHP, the Internet would crash.<|eor|><|sor|>Or PHP would become a lot better<|eor|><|eols|><|endoftext|>
5
lolphp
hedgehog1024
fb75yah
<|sols|><|sot|>int is short for "integer", bool is short for "boolean", yet php has FILTER_VALIDATE_INT but not FILTER_VALIDATE_INTEGER, we have FILTER_VALIDATE_BOOLEAN but not FILTER_VALIDATE_BOOL<|eot|><|sol|>https://3v4l.org/36hUH<|eol|><|sor|>Would adding them both for consistency sake be better?<|eor|><|soopr|>Yes. (actually im just grumpy because a FILTER\_VALIDATE\_BOOL caused a syntax error in my code while the FILTER\_VALIDATE\_INT next to it didn't, then i had to friggin look it up in the docs and.. yeah, grumpy)<|eoopr|><|sor|>Can you link your PR?<|eor|><|sor|>If there were a PR for every LOLPHP, the Internet would crash.<|eor|><|sor|>Or PHP would become a lot better<|eor|><|sor|>A lol better<|eor|><|eols|><|endoftext|>
5
lolphp
kirillsimin
5ej086
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|eols|><|endoftext|>
63
lolphp
SnowdogU77
dacygia
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>A string containing the number 0 is not empty either.<|eor|><|sor|>[deleted]<|eor|><|sor|>_ I shall now sing the song of /r/lolphp's people Just because it's documented, doesn't mean it's right <|eor|><|eols|><|endoftext|>
79
lolphp
OmnipotentEntity
dacwtl2
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>A string containing the number 0 is not empty either.<|eor|><|eols|><|endoftext|>
59
lolphp
SnowdogU77
dad015m
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>A string containing the number 0 is not empty either.<|eor|><|sor|>[deleted]<|eor|><|sor|>_ I shall now sing the song of /r/lolphp's people Just because it's documented, doesn't mean it's right <|eor|><|sor|>[deleted]<|eor|><|sor|>Because it's unexpected. Even if it's widely documented, this is not a circumstance in which a programmer expects the type to be coerced. Type coercion only makes sense if the function that the item is passed to is expecting a specific type. Checking a string for emptiness should not result in false if the length is greater than zero, especially considering the fact that strings are represented as lists of characters. Truth checking index 0 when you pass a string is completely unexpected behavior. The problem with PHP is the first point in the paragraph above. PHP coerces types when it shouldn't fairly consistently, but just because it consistently does something wrong doesn't make that behavior right. I will use a hypothetical and hyperbolized comparison. You buy a rifle from a gun store. It looks identical to every other rifle on the shelf, and you hear people talk about it constantly. In the manual, it states repeatedly that the gun shoots backwards. The problem is that *most every other gun shoots forwards*, so you aren't expecting the gun to shoot backwards. Long story short, you have a bullet through your shoulder after your hunting trip.<|eor|><|eols|><|endoftext|>
43
lolphp
xiata
dadb9qn
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>A string containing the number 0 is not empty either.<|eor|><|sor|>[deleted]<|eor|><|sor|>_ I shall now sing the song of /r/lolphp's people Just because it's documented, doesn't mean it's right <|eor|><|sor|>[deleted]<|eor|><|sor|>Because it's unexpected. Even if it's widely documented, this is not a circumstance in which a programmer expects the type to be coerced. Type coercion only makes sense if the function that the item is passed to is expecting a specific type. Checking a string for emptiness should not result in false if the length is greater than zero, especially considering the fact that strings are represented as lists of characters. Truth checking index 0 when you pass a string is completely unexpected behavior. The problem with PHP is the first point in the paragraph above. PHP coerces types when it shouldn't fairly consistently, but just because it consistently does something wrong doesn't make that behavior right. I will use a hypothetical and hyperbolized comparison. You buy a rifle from a gun store. It looks identical to every other rifle on the shelf, and you hear people talk about it constantly. In the manual, it states repeatedly that the gun shoots backwards. The problem is that *most every other gun shoots forwards*, so you aren't expecting the gun to shoot backwards. Long story short, you have a bullet through your shoulder after your hunting trip.<|eor|><|sor|>[deleted]<|eor|><|sor|>A string with a character isn't empty. The conversion should not happen. <|eor|><|eols|><|endoftext|>
24
lolphp
xiata
dadc5qc
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>_ I shall now sing the song of /r/lolphp's people Just because it's documented, doesn't mean it's right <|eor|><|sor|>[deleted]<|eor|><|sor|>Because it's unexpected. Even if it's widely documented, this is not a circumstance in which a programmer expects the type to be coerced. Type coercion only makes sense if the function that the item is passed to is expecting a specific type. Checking a string for emptiness should not result in false if the length is greater than zero, especially considering the fact that strings are represented as lists of characters. Truth checking index 0 when you pass a string is completely unexpected behavior. The problem with PHP is the first point in the paragraph above. PHP coerces types when it shouldn't fairly consistently, but just because it consistently does something wrong doesn't make that behavior right. I will use a hypothetical and hyperbolized comparison. You buy a rifle from a gun store. It looks identical to every other rifle on the shelf, and you hear people talk about it constantly. In the manual, it states repeatedly that the gun shoots backwards. The problem is that *most every other gun shoots forwards*, so you aren't expecting the gun to shoot backwards. Long story short, you have a bullet through your shoulder after your hunting trip.<|eor|><|sor|>[deleted]<|eor|><|sor|>A string with a character isn't empty. The conversion should not happen. <|eor|><|sor|>[deleted]<|eor|><|sor|>Because they attempt to bring their stupid ideas to other languages. A language that fails to fix its behaviors, instead documenting its faults as accepted standard, deserves ridicule. By all means keep defending stupid ideas. For the record, I write fuck tons of js for a living, and it does have a lot of faults that are as bad as this language. Difference is, I'm not defending it. I'd like those stupid problems to go away. <|eor|><|eols|><|endoftext|>
23
lolphp
Vakieh
dacz1ko
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>A string containing the number 0 is not empty either.<|eor|><|sor|>[deleted]<|eor|><|sor|>Lolphp isn't a surprise, it's a (valid) assumption of stupidity. The issue here is the automatic conversion - it should only happen under circumstances where a string parameter would cause a fundamental error, like a sum function.<|eor|><|eols|><|endoftext|>
21
lolphp
Grimy_
dakm3p9
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>Wait, it gets better! `empty("0")` is true, but `empty(" 0")` is false, even though `" 0" == "0"`!<|eor|><|eols|><|endoftext|>
20
lolphp
Vakieh
dad2nl9
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>A string containing the number 0 is not empty either.<|eor|><|sor|>[deleted]<|eor|><|sor|>Lolphp isn't a surprise, it's a (valid) assumption of stupidity. The issue here is the automatic conversion - it should only happen under circumstances where a string parameter would cause a fundamental error, like a sum function.<|eor|><|sor|>It should only happen under predictable circumstances.<|eor|><|sor|>If you know your car's windows can't go down on Tuesdays, that is a state which is predictable, but still wrong. That's what we have here - PHP is (mostly) deterministic, but that doesn't change the fact that the way it works is wrong.<|eor|><|eols|><|endoftext|>
17
lolphp
phreakocious
dad6fgl
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>Rails is so much better: https://i.stack.imgur.com/oXuhJ.png ..not Or JavaScript: http://stackoverflow.com/questions/7615214/in-javascript-why-is-0-equal-to-false-but-when-tested-by-if-it-is-not-fals<|eor|><|sor|>Pure Ruby is quite consistent and sensible. Rails adds blank? and present?, which feel slightly odd.<|eor|><|eols|><|endoftext|>
14
lolphp
egrgssdfgsarg
dadjdfs
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>A string containing the number 0 is not empty either.<|eor|><|sor|>[deleted]<|eor|><|sor|>_ I shall now sing the song of /r/lolphp's people Just because it's documented, doesn't mean it's right <|eor|><|sor|>[deleted]<|eor|><|sor|>Because it's unexpected. Even if it's widely documented, this is not a circumstance in which a programmer expects the type to be coerced. Type coercion only makes sense if the function that the item is passed to is expecting a specific type. Checking a string for emptiness should not result in false if the length is greater than zero, especially considering the fact that strings are represented as lists of characters. Truth checking index 0 when you pass a string is completely unexpected behavior. The problem with PHP is the first point in the paragraph above. PHP coerces types when it shouldn't fairly consistently, but just because it consistently does something wrong doesn't make that behavior right. I will use a hypothetical and hyperbolized comparison. You buy a rifle from a gun store. It looks identical to every other rifle on the shelf, and you hear people talk about it constantly. In the manual, it states repeatedly that the gun shoots backwards. The problem is that *most every other gun shoots forwards*, so you aren't expecting the gun to shoot backwards. Long story short, you have a bullet through your shoulder after your hunting trip.<|eor|><|sor|>[deleted]<|eor|><|sor|>When you have that much magic behavior it puts a large burden on the programmer to learn all of it. Scenario: Initial Programmer: > A function named `empty` hmm sounds like I can use it to check all my form elements are filled in. Hmm, if it's empty I'll throw an error. Yay, seems like everything is working. No issues occur for months. The first guy leaves to work on newer and better projects that aren't in PHP, A replacement gets hired. Someone from the business decides they want to ask, in a text box. > "How many cats do you own? If you have any, what are there names?" People go along typing things like "Zero cats" etc. Months go by without issue. Eventually one user complains. > "I can't get your form to work. It keeps telling me I didn't fill out how many cats I own, when I totally did." The new programmer eventually figures it out ahh, the user typed exactly `0`, which happens to be coerced to a number and empty evaluate to true. Figures out hmm, the original programmer probably wanted `array_key_exists`. The problem is, this already resulted in a user facing error and an hour of time or so wasted because PHP chose to do the unintuitive thing. Now, it could have been better documented. The initial programmer could have thoroughly read the documentation for empty. They could have written tests for this exact scenario if they expected it to come up. The user could have tried changing their answer when they got the error message. But why do you want to use a language where issues like this are commonplace?<|eor|><|eols|><|endoftext|>
13
lolphp
Cuddlefluff_Grim
daduek5
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>Rails is so much better: https://i.stack.imgur.com/oXuhJ.png ..not Or JavaScript: http://stackoverflow.com/questions/7615214/in-javascript-why-is-0-equal-to-false-but-when-tested-by-if-it-is-not-fals<|eor|><|sor|>C#: Null - Type error 0 - Type error 1 - Type error new Object() - Type error "" - Type error " " - Type error "1" - Type error "0" - Type error "true" - Type error "false" - Type error new bool[] { true } - Type error new { } - Type error true - True false - False <|eor|><|eols|><|endoftext|>
12
lolphp
Grimy_
dakm5ok
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>Yes, I agree, the string `"0"` shouldnt be called empty. Thats kinda the point of this lolphp.<|eor|><|eols|><|endoftext|>
10
lolphp
xiata
daebp84
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>Nah, I don't agree with this being a lolphp either. Don't try to cast strings to boolean unless you're writing the conversion yourself, or are using very rigidly defined functions. Ex. C# has IsNullOrWhitespace which performs exactly how you'd expect.<|eor|><|sor|>It definitely does belong. Empty is taking a non empty string and doing a bogus conversion to 0 which then converts again to false. For this function, there should be absolutely no conversions, explicitly handling the different types properly. <|eor|><|eols|><|endoftext|>
9
lolphp
xiongchiamiov
dad29ct
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>[deleted]<|eor|><|sor|>A string containing the number 0 is not empty either.<|eor|><|sor|>That depends on whether you prefer strong or weak typing. *I* think strong typing is a much better way to avoid bugs, but plenty of respected languages are fairly weakly-typed.<|eor|><|eols|><|endoftext|>
9
lolphp
xiata
daf0w3j
<|sols|><|sot|>Space is not falsy, but string containing zero is.<|eot|><|sol|>https://i.redd.it/rksqofj22fzx.png<|eol|><|sor|>Nah, I don't agree with this being a lolphp either. Don't try to cast strings to boolean unless you're writing the conversion yourself, or are using very rigidly defined functions. Ex. C# has IsNullOrWhitespace which performs exactly how you'd expect.<|eor|><|sor|>It definitely does belong. Empty is taking a non empty string and doing a bogus conversion to 0 which then converts again to false. For this function, there should be absolutely no conversions, explicitly handling the different types properly. <|eor|><|sor|>I'm *not sure* I follow. Treating whitespace as empty - I don't think I agree with that at a gut level. But that might be tempered by the languages I tend to work in which don't often contain the notion of "empty" Do you think " " is an empty string?<|eor|><|sor|>Sorry, wasn't clear. Just whitespace isn't empty, it is also considering "0" as empty. Which no, it is a string with a character, which isn't empty. <|eor|><|eols|><|endoftext|>
9
lolphp
TheBuzzSaw
4ael29
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|eols|><|endoftext|>
58
lolphp
tdammers
d0zu6ye
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>> On its own, runkit is a very dangerous extension. It lets you change constants, functions, and classes while the script that uses them is running. In essence, its like a tool that lets you rebuild a plane during the flight. Sounds like PHP, alright<|eor|><|sor|>In all fairness, PHP considers this a rather esoteric feature, while to the folks over in Clojure land, attaching a REPL to a live production application and replacing whole *modules* on-the-fly is called "Tuesday". Which is a bit like taking off in a zeppeling, dismantling it mid-flight, and then *inventing* the airplane and assembling a working specimen just in time before you hit the ground.<|eor|><|eols|><|endoftext|>
57
lolphp
beerdude26
d0zpam8
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>> On its own, runkit is a very dangerous extension. It lets you change constants, functions, and classes while the script that uses them is running. In essence, its like a tool that lets you rebuild a plane during the flight. Sounds like PHP, alright<|eor|><|eols|><|endoftext|>
56
lolphp
PlasmaSheep
d10ce8i
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>>three million lines of PHP holy fuck<|eor|><|sor|>How the fuck do they have 3 million lines of code for a glorified newspaper classifieds section? That's more than the space shuttle, linux 2.2, and the lhc.<|eor|><|eols|><|endoftext|>
37
lolphp
boxingdog
d108llm
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>>three million lines of PHP holy fuck<|eor|><|eols|><|endoftext|>
29
lolphp
SaraMG
d110u5l
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>> On its own, runkit is a very dangerous extension. It lets you change constants, functions, and classes while the script that uses them is running. In essence, its like a tool that lets you rebuild a plane during the flight. Sounds like PHP, alright<|eor|><|sor|>As runkit's author, I cringe every time I see it used.<|eor|><|eols|><|endoftext|>
23
lolphp
TheBuzzSaw
d0zod6s
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|soopr|>> The idea that databases are a bottleneck in web-projects is an all-too-common misconception. Been saying this for years, but no one listens. "Performance doesn't matter." ... until it does.<|eoopr|><|eols|><|endoftext|>
22
lolphp
cbraga
d0zoq7p
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|soopr|>> The idea that databases are a bottleneck in web-projects is an all-too-common misconception. Been saying this for years, but no one listens. "Performance doesn't matter." ... until it does.<|eoopr|><|sor|>He writes that then two paragraphs down he goes on to write: > In PHP web apps, the processor consumes as much as any dynamic high-level language a lot. But PHP developers have faced a particular obstacle (one that has made them the victims of vicious trolling from various communities): the absence of JIT or, at the very least, a generator of compilable texts in languages like C/C++. My fucking sides. Who could've thought that not having to compile your whole source code for every single page request could be a good idea? (FastCGI came out in 1996 -- get on with the times you're 20 years behind) Yeah, your database isn't the bottleneck? *No fucking shit!*<|eor|><|eols|><|endoftext|>
22
lolphp
RetardedSquirrel
d10iu11
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>>three million lines of PHP holy fuck<|eor|><|sor|>How the fuck do they have 3 million lines of code for a glorified newspaper classifieds section? That's more than the space shuttle, linux 2.2, and the lhc.<|eor|><|sor|>Outsourcing.<|eor|><|eols|><|endoftext|>
22
lolphp
nikic
d0zx7rv
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|soopr|>> The idea that databases are a bottleneck in web-projects is an all-too-common misconception. Been saying this for years, but no one listens. "Performance doesn't matter." ... until it does.<|eoopr|><|sor|>He writes that then two paragraphs down he goes on to write: > In PHP web apps, the processor consumes as much as any dynamic high-level language a lot. But PHP developers have faced a particular obstacle (one that has made them the victims of vicious trolling from various communities): the absence of JIT or, at the very least, a generator of compilable texts in languages like C/C++. My fucking sides. Who could've thought that not having to compile your whole source code for every single page request could be a good idea? (FastCGI came out in 1996 -- get on with the times you're 20 years behind) Yeah, your database isn't the bottleneck? *No fucking shit!*<|eor|><|sor|>I'm not sure I follow your implication. PHP is usually deployed using FastCGI process pools with a shared memory opcode cache. If you think any sane deployment would recompile the entire codebase on each request, you have been most severely misinformed.<|eor|><|eols|><|endoftext|>
22
lolphp
SituationSoap
d10nmr2
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>"We have 3 million lines of code and high confidence in its fitness despite the fact that we know we have developers who write untested code and our test suite covers less than 50% of our code base. We deploy twice a day. Nobody checks whether the things deployed break anything or work how they should except our automated test suite." I'm actively questioning the intelligence of the leadership team at Badoo who thought that publishing this document in this form was somehow supposed to be showing good things about their organization.<|eor|><|eols|><|endoftext|>
20
lolphp
BilgeXA
d103w3x
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|soopr|>> The idea that databases are a bottleneck in web-projects is an all-too-common misconception. Been saying this for years, but no one listens. "Performance doesn't matter." ... until it does.<|eoopr|><|sor|>He writes that then two paragraphs down he goes on to write: > In PHP web apps, the processor consumes as much as any dynamic high-level language a lot. But PHP developers have faced a particular obstacle (one that has made them the victims of vicious trolling from various communities): the absence of JIT or, at the very least, a generator of compilable texts in languages like C/C++. My fucking sides. Who could've thought that not having to compile your whole source code for every single page request could be a good idea? (FastCGI came out in 1996 -- get on with the times you're 20 years behind) Yeah, your database isn't the bottleneck? *No fucking shit!*<|eor|><|sor|>I'm not sure I follow your implication. PHP is usually deployed using FastCGI process pools with a shared memory opcode cache. If you think any sane deployment would recompile the entire codebase on each request, you have been most severely misinformed.<|eor|><|sor|>But what about his fucking sides. You can't argue with that.<|eor|><|eols|><|endoftext|>
20
lolphp
headzoo
d10e05q
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>> On its own, runkit is a very dangerous extension. It lets you change constants, functions, and classes while the script that uses them is running. In essence, its like a tool that lets you rebuild a plane during the flight. Sounds like PHP, alright<|eor|><|sor|>Doesn't Ruby also let you [redefine class members](http://rubylearning.com/satishtalim/ruby_open_classes.html) at runtime? Even core classes?<|eor|><|eols|><|endoftext|>
10
lolphp
berkes
d10nrtz
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>I mean, CPython and Ruby aren't JIT compiled, either. Although Python does have PyPy for that...<|eor|><|sor|>I usually think that people who argue "language X is bad because it does not have Y" is bullshit. PHP is not crap because it does not have a JIT, or because it has a JIT, or whatever. It's crap because it's compiler is a mess. PHP is not crap because it has weak typing or duck-typing, or whatevertyping Its crap because it's type-comparison is probably the most random and inconsistent one around. PHP is crap because in some places it really is more of a RandomlyTyped language. Saying PHP is stupid because it lacks a JIT compiler is like a Python dev arguing that Erlang is dumb because it requires brackets and cannot infer blocks of code based on spacing.<|eor|><|eols|><|endoftext|>
10
lolphp
dagbrown
d10f6sg
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|soopr|>> The idea that databases are a bottleneck in web-projects is an all-too-common misconception. Been saying this for years, but no one listens. "Performance doesn't matter." ... until it does.<|eoopr|><|sor|>He writes that then two paragraphs down he goes on to write: > In PHP web apps, the processor consumes as much as any dynamic high-level language a lot. But PHP developers have faced a particular obstacle (one that has made them the victims of vicious trolling from various communities): the absence of JIT or, at the very least, a generator of compilable texts in languages like C/C++. My fucking sides. Who could've thought that not having to compile your whole source code for every single page request could be a good idea? (FastCGI came out in 1996 -- get on with the times you're 20 years behind) Yeah, your database isn't the bottleneck? *No fucking shit!*<|eor|><|sor|>I'm not sure I follow your implication. PHP is usually deployed using FastCGI process pools with a shared memory opcode cache. If you think any sane deployment would recompile the entire codebase on each request, you have been most severely misinformed.<|eor|><|sor|>Shared hosting sysadmin here! PHP runs as CGI scripts. Every PHP page is loaded and compiled before being executed. No FastCGI process pools, no shared memory opcode cache, just tons and tons of fork(), exec(), and interpretation.<|eor|><|eols|><|endoftext|>
10
lolphp
cube-drone
d0zx2hg
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>I mean, CPython and Ruby aren't JIT compiled, either. Although Python does have PyPy for that...<|eor|><|eols|><|endoftext|>
9
lolphp
berkes
d10ne85
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|sor|>> On its own, runkit is a very dangerous extension. It lets you change constants, functions, and classes while the script that uses them is running. In essence, its like a tool that lets you rebuild a plane during the flight. Sounds like PHP, alright<|eor|><|sor|>Doesn't Ruby also let you [redefine class members](http://rubylearning.com/satishtalim/ruby_open_classes.html) at runtime? Even core classes?<|eor|><|sor|>Yes. And it is one of the reasons why you really cannot developer without having at least 100% test coverage: "over 100%" if you count both unit test 100% and your integration tests. It is also very much a "don't use unless you really know what you are doing thing". But *if* you know what you are doing (and you've covered your ass with tests) it can be really powerful. This one funky lib is doing something stupid that breaks your parallel execution? class FunkyLib::Report def save_with_mutex GlobalMutex.lock(id) do save_without_mutex end end alias_method :save_without_mutex, :save alias_method :save, :save_with_mutex end A rather common pattern to reopen an existing class, rename its old method, add your own method and replace the old method with yours. Obviously, one should be very careful and only use this when there's no proper solution (like writing your own MutextedReport Adapter or such). But, in the end, it is a tool in your toolbox. And when used properly, a really powerful one. Like how a chainsaw really is a powerful tool, but you'd be really dumb to use one when slicing bread.<|eor|><|eols|><|endoftext|>
9
lolphp
wweber
d0zxd73
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|soopr|>> The idea that databases are a bottleneck in web-projects is an all-too-common misconception. Been saying this for years, but no one listens. "Performance doesn't matter." ... until it does.<|eoopr|><|sor|>For your average request, shouldn't your database always be the bottleneck? From a very simple perspective, your web application is just a very fancy way of accessing a database, so if your application performs worse than actually getting the data from a database I would imagine you have a problem.<|eor|><|eols|><|endoftext|>
7
lolphp
TheBuzzSaw
d10slc5
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|soopr|>> The idea that databases are a bottleneck in web-projects is an all-too-common misconception. Been saying this for years, but no one listens. "Performance doesn't matter." ... until it does.<|eoopr|><|sor|>For your average request, shouldn't your database always be the bottleneck? From a very simple perspective, your web application is just a very fancy way of accessing a database, so if your application performs worse than actually getting the data from a database I would imagine you have a problem.<|eor|><|soopr|>> For your average request, shouldn't your database always be the bottleneck? The database request is certainly the _slowest_ component, but it only becomes a "bottleneck" because everyone mindlessly blocks on the query, which results in other components contributing to the overall slowness. In a proper language, I can start the query on a worker thread while I continue doing other things (loading templates, etc.). If your profile shows that you have 500ms going to your query and 100ms going to your code, you optimize the query. However, if you only manage to reduce your query time to 450ms, you still shouldn't give up and ignore everything else. If I can do something to reduce the code time from 100ms to 10ms, of course I'm going to do it. After all, a 90ms gain is better than the 50ms gain. If I stuck with the universal wisdom that "the database is the bottleneck", I would have overlooked other perfectly good improvements to be made.<|eoopr|><|eols|><|endoftext|>
7
lolphp
Cuddlefluff_Grim
d11vbnq
<|sols|><|sot|>How Badoo lost one million dollars using PHP in the first place<|eot|><|sol|>https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/<|eol|><|soopr|>> The idea that databases are a bottleneck in web-projects is an all-too-common misconception. Been saying this for years, but no one listens. "Performance doesn't matter." ... until it does.<|eoopr|><|sor|>For your average request, shouldn't your database always be the bottleneck? From a very simple perspective, your web application is just a very fancy way of accessing a database, so if your application performs worse than actually getting the data from a database I would imagine you have a problem.<|eor|><|soopr|>> For your average request, shouldn't your database always be the bottleneck? The database request is certainly the _slowest_ component, but it only becomes a "bottleneck" because everyone mindlessly blocks on the query, which results in other components contributing to the overall slowness. In a proper language, I can start the query on a worker thread while I continue doing other things (loading templates, etc.). If your profile shows that you have 500ms going to your query and 100ms going to your code, you optimize the query. However, if you only manage to reduce your query time to 450ms, you still shouldn't give up and ignore everything else. If I can do something to reduce the code time from 100ms to 10ms, of course I'm going to do it. After all, a 90ms gain is better than the 50ms gain. If I stuck with the universal wisdom that "the database is the bottleneck", I would have overlooked other perfectly good improvements to be made.<|eoopr|><|sor|>Databases are no more a bottleneck than the web front-end. The trade-off for speed in databases are updates/insertions/deletions, RAM and disk space. If you don't mind that, then you can get most queries to execute in a fraction of a millisecond. I get a feeling that people violently underestimate the speed of a properly designed database, and just use it as a rationale for why their website has unnecessarily sub-par performance.<|eor|><|eols|><|endoftext|>
7
lolphp
n1c0_ds
21esxf
<|sols|><|sot|>htmlentities only displays an error when display_errors is off<|eot|><|sol|>http://insomanic.me.uk/post/191397106/php-htmlspecialchars-htmlentities-invalid<|eol|><|eols|><|endoftext|>
59
lolphp
n1c0_ds
cgcbltn
<|sols|><|sot|>htmlentities only displays an error when display_errors is off<|eot|><|sol|>http://insomanic.me.uk/post/191397106/php-htmlspecialchars-htmlentities-invalid<|eol|><|soopr|>Don't worry though, [it's intentional](https://bugs.php.net/bug.php?id=47494)!<|eoopr|><|eols|><|endoftext|>
25
lolphp
nahguri
cgce26r
<|sols|><|sot|>htmlentities only displays an error when display_errors is off<|eot|><|sol|>http://insomanic.me.uk/post/191397106/php-htmlspecialchars-htmlentities-invalid<|eol|><|soopr|>Don't worry though, [it's intentional](https://bugs.php.net/bug.php?id=47494)!<|eoopr|><|sor|>I have no words. <|eor|><|eols|><|endoftext|>
13
lolphp
n1c0_ds
cgce7g9
<|sols|><|sot|>htmlentities only displays an error when display_errors is off<|eot|><|sol|>http://insomanic.me.uk/post/191397106/php-htmlspecialchars-htmlentities-invalid<|eol|><|soopr|>Don't worry though, [it's intentional](https://bugs.php.net/bug.php?id=47494)!<|eoopr|><|sor|>I have no words. <|eor|><|soopr|>Mine was a muted "Fuck." This will be my last PHP project. There is a code freeze in two weeks, and I'm out in a month (internship). Between that and PDO refusing to throw exceptions, I have given up. I just work on making the next guy's job easier.<|eoopr|><|eols|><|endoftext|>
12