subreddit stringclasses 7
values | author stringlengths 3 20 | id stringlengths 5 7 | content stringlengths 67 30.4k | score int64 0 140k |
|---|---|---|---|---|
lolphp | ilogik | 2ex6o2 | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|eoss|><|endoftext|> | 49 |
lolphp | HelloAnnyong | ck3sy8q | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>> Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
I like how it does not actually explain what it really does. Just that it's "similar" to `break`ing out of a loop.<|eor|><|eoss|><|endoftext|> | 30 |
lolphp | smog_alado | ck3y44x | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>> Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
I like how it does not actually explain what it really does. Just that it's "similar" to `break`ing out of a loop.<|eor|><|sor|>I also like how they say "some other languages" instead of "every other language with a C-like switch statement"<|eor|><|eoss|><|endoftext|> | 23 |
lolphp | expugnator3000 | ck3wsl5 | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>> Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
I like how it does not actually explain what it really does. Just that it's "similar" to `break`ing out of a loop.<|eor|><|soopr|>my guess is that because you can use break in loops and in a switch statement, as a shortcut switch is actually considered to be a loop, so, naturally, continue will also work there as well.
probably somebody being lazy when they first wrote the parser.
now they can't fix it, because it would break existing code<|eoopr|><|sor|>> switch is actually considered to be a loop
Classic PHP<|eor|><|eoss|><|endoftext|> | 18 |
lolphp | ilogik | ck3yikb | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>> Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
I like how it does not actually explain what it really does. Just that it's "similar" to `break`ing out of a loop.<|eor|><|sor|>I also like how they say "some other languages" instead of "every other language with a C-like switch statement"<|eor|><|soopr|>yeah, like they're trying to suggest that either way is commonly found, and is perfect valid, not that it's a quirk in PHP<|eoopr|><|eoss|><|endoftext|> | 14 |
lolphp | tdammers | ck3wc4x | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>Heh, for a moment I thought you meant the sneaky `;` after the `case 5`... I don't even know what that does in PHP, but my guess would be either a parser error, or something like somehow messing up the switch statement and executing what looks like a `case` branch somewhere else.<|eor|><|eoss|><|endoftext|> | 13 |
lolphp | ilogik | ck3ygxr | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>I just read the documentation on this today so I got it right. Yesterday i would have been perplexed.
Edit: I don't really like the way this bit of code was written. I'm guessing that it is to print everything except certain values?
Why not use an array of the values and `in_array`?
Or perhaps, if speed is important (lots of values to check against), set the values as keys in the array (just set the value to true) and use isset instead of in_array (this assumes that the values you are testing can be an array key)
<|eor|><|soopr|>you are right, I would never write code like that.
I just used that as an example to illustrate the behaviour, it was the simplest code I could come up with<|eoopr|><|eoss|><|endoftext|> | 9 |
lolphp | suspiciously_calm | ck484sy | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>> Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
I like how it does not actually explain what it really does. Just that it's "similar" to `break`ing out of a loop.<|eor|><|soopr|>my guess is that because you can use break in loops and in a switch statement, as a shortcut switch is actually considered to be a loop, so, naturally, continue will also work there as well.
probably somebody being lazy when they first wrote the parser.
now they can't fix it, because it would break existing code<|eoopr|><|sor|>> switch is actually considered to be a loop
Classic PHP<|eor|><|sor|>Because when it *doesn't make sense,* then they *can* re-use the same codepaths.<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | Banane9 | ck4goel | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>> Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
I like how it does not actually explain what it really does. Just that it's "similar" to `break`ing out of a loop.<|eor|><|soopr|>my guess is that because you can use break in loops and in a switch statement, as a shortcut switch is actually considered to be a loop, so, naturally, continue will also work there as well.
probably somebody being lazy when they first wrote the parser.
now they can't fix it, because it would break existing code<|eoopr|><|sor|>\*air quotes\* *Parser*<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | ilogik | ck3tkzo | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>> Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
I like how it does not actually explain what it really does. Just that it's "similar" to `break`ing out of a loop.<|eor|><|soopr|>my guess is that because you can use break in loops and in a switch statement, as a shortcut switch is actually considered to be a loop, so, naturally, continue will also work there as well.
probably somebody being lazy when they first wrote the parser.
now they can't fix it, because it would break existing code<|eoopr|><|eoss|><|endoftext|> | 5 |
lolphp | Banane9 | ck6oaia | <|soss|><|sot|>what do you think this will output?<|eot|><|sost|> <?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5:
continue;
}
echo $i;
}
This actually caused a bug in production code. Our expectation was that this will output 246.
The actual output is 123456
Granted, this is [documented](http://php.net/manual/en/control-structures.switch.php), but for someone coming from another language this is just weird.
> Note that **unlike some other languages**, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
<|eost|><|sor|>"continue 2"...? Like this?
<?php
$a = array(1, 2, 3, 4, 5, 6);
foreach ($a as $i)
{
switch ($i){
case 1:
case 3:
case 5;
continue2;
}
echo $i;
}
<|eor|><|sor|>That clearly stands for "*continue to* loop", don't you see?!<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | fnzp | 2cb2y0 | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|eols|><|endoftext|> | 48 |
lolphp | andronikus | cjdz9y4 | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>When I heard there wasn't a language spec, at first I was surprised. And then I was deeply unsurprised.<|eor|><|eols|><|endoftext|> | 22 |
lolphp | midir | cje425r | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>That's like drawing a map of a turd.<|eor|><|eols|><|endoftext|> | 19 |
lolphp | more_exercise | cjegah9 | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>I laughed out loud reading the specification for the application of prefix ++/-- to empty strings. <|eor|><|sor|>For the lazy:
>For a prefix -- operator used with an operand whose value is an empty string, the side effect is that the operand's type is changed to int, the operand's value is set to zero, and that value is decremented by 1. The result is the value of the operand after it has been incremented.
>For a prefix ++ operator used with an operand whose value is an empty string, the side effect is that the operand's value is changed to the string "1". The type of the operand is unchanged. The result is the new value of the operand.
<|eor|><|eols|><|endoftext|> | 18 |
lolphp | graingert | cjdylyn | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|soopr|>How will this work?
Facebook developers: Here's your awesome PHP spec! Just make sure any new version you release matches the spec okay?
PHP developers: You're not the boss of me. [changes every function in PHP to be slightly different]
<|eoopr|><|sor|>The spec doesn't cover the standard library or any of the funky functions.<|eor|><|eols|><|endoftext|> | 18 |
lolphp | maxufimo | cjebykp | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>You'd think at some point along the way the Facebook devs would have realized they should just use a better language rather than trying to save a sinking ship.<|eor|><|sor|>You'd think so. But we are talking Facebook here, the company which went a long way to build [a custom version control solution](https://code.facebook.com/posts/218678814984400/scaling-mercurial-at-facebook/) in order to handle their monolithic 2 GB codebase instead of splitting the code into smaller, separate pieces.
Y'know, PHP and monolithic repository really works for them, why'd they change it?<|eor|><|eols|><|endoftext|> | 17 |
lolphp | allthediamonds | cjdwii8 | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>Actually it's pretty well thought. It's a first step, but if you look at it, you'll see that it defines some of PHP's crazies as "implementation defined"; the implementations being "what the Zend Engine does" and "what a reasonable engine would do instead".<|eor|><|eols|><|endoftext|> | 16 |
lolphp | _vec_ | cjehsyu | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>I laughed out loud reading the specification for the application of prefix ++/-- to empty strings. <|eor|><|sor|>For the lazy:
>For a prefix -- operator used with an operand whose value is an empty string, the side effect is that the operand's type is changed to int, the operand's value is set to zero, and that value is decremented by 1. The result is the value of the operand after it has been incremented.
>For a prefix ++ operator used with an operand whose value is an empty string, the side effect is that the operand's value is changed to the string "1". The type of the operand is unchanged. The result is the new value of the operand.
<|eor|><|sor|>The rest of that section is pretty good too:
> For a prefix -- or ++ operator used with a numeric string, the numeric string is treated as the corresponding int or float value.
> For a prefix -- operator used with a non-numeric string-valued operand, there is no side effect, and the result is the operand's value.
> For a non-numeric string-valued operand that contains only alphanumeric characters, for a prefix ++ operator, the operand is considered to be a pseudo-base-36 number (i.e., with digits 09 followed by AZ or az) in which letter case is ignored for value purposes. The right-most digit is incremented by 1. For the digits 08, that means going to 19. For the letters "A""Y" (or "a""y"), that means going to "B""Z" (or "b""z"). For the digit 9, the digit becomes 0, and the carry is added to the next left-most digit, and so on. For the digit "Z" (or "z"), the resulting string has an extra digit "A" (or "a") appended. For example, when incrementing, "a" -> "b", "X" -> "AA", "AA" -> "AB", "F29" -> "F30", "FZ9" -> "GA0", and "ZZ9" -> "AAA0". A digit position containing a number wraps modulo-10, while a digit position containing a letter wraps modulo-26.
> For a non-numeric string-valued operand that contains any non-alphanumeric characters, for a prefix ++ operator, all characters up to and including the right-most non-alphanumeric character is passed through to the resulting string, unchanged. Characters to the right of that right-most non-alphanumeric character are treated like a non-numeric string-valued operand that contains only alphanumeric characters, except that the resulting string will not be extended. Instead, a digit position containing a number wraps modulo-10, while a digit position containing a letter wraps modulo-26.
On the one hand, kudos for the clear, concise explanation of some very complicated behavior. On the other hand, WTF?!<|eor|><|eols|><|endoftext|> | 16 |
lolphp | tdammers | cjdrtl8 | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>Lol, "tradition"...<|eor|><|eols|><|endoftext|> | 15 |
lolphp | T3hUb3rK1tten | cje319q | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>You'd think at some point along the way the Facebook devs would have realized they should just use a better language rather than trying to save a sinking ship.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | fnzp | cjdvciw | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|soopr|>How will this work?
Facebook developers: Here's your awesome PHP spec! Just make sure any new version you release matches the spec okay?
PHP developers: You're not the boss of me. [changes every function in PHP to be slightly different]
<|eoopr|><|eols|><|endoftext|> | 15 |
lolphp | Drainedsoul | cje4lmz | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>I laughed out loud reading the specification for the application of prefix ++/-- to empty strings. <|eor|><|eols|><|endoftext|> | 14 |
lolphp | polish_niceguy | cjdxpot | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>Actually it's pretty well thought. It's a first step, but if you look at it, you'll see that it defines some of PHP's crazies as "implementation defined"; the implementations being "what the Zend Engine does" and "what a reasonable engine would do instead".<|eor|><|sor|>> the implementations being "what the Zend Engine does" and "what a reasonable engine would do instead" and "what the actual fuck".
There, FTFY.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | _vec_ | cjec8mg | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>You'd think at some point along the way the Facebook devs would have realized they should just use a better language rather than trying to save a sinking ship.<|eor|><|sor|>Unfortunately at this point they probably can't. Whatever else you can say about Facebook, they're not stupid. And they're not the type of company to engage in massive CompSci research projects solely for the hell of it. They've obviously decided that hiring an army of PhDs to write saner runtimes for PHP and MySQL is less expensive than trying to rewrite their huge codebase and retool their gargantuan infrastructure.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | ElusiveGuy | cjesxj6 | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>Actually it's pretty well thought. It's a first step, but if you look at it, you'll see that it defines some of PHP's crazies as "implementation defined"; the implementations being "what the Zend Engine does" and "what a reasonable engine would do instead".<|eor|><|sor|>> the implementations being "what the Zend Engine does" and "what a reasonable engine would do instead" and "what the actual fuck".
There, FTFY.<|eor|><|sor|>The first and third are often the same thing.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | merreborn | cjeckdm | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>You'd think at some point along the way the Facebook devs would have realized they should just use a better language rather than trying to save a sinking ship.<|eor|><|sor|>Unfortunately at this point they probably can't. Whatever else you can say about Facebook, they're not stupid. And they're not the type of company to engage in massive CompSci research projects solely for the hell of it. They've obviously decided that hiring an army of PhDs to write saner runtimes for PHP and MySQL is less expensive than trying to rewrite their huge codebase and retool their gargantuan infrastructure.<|eor|><|sor|>The team that wrote the initial version of hip hop was actually very small. Writing php interpreter is easier than rewriting Facebook<|eor|><|eols|><|endoftext|> | 7 |
lolphp | gearvOsh | cjed6mk | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|soopr|>How will this work?
Facebook developers: Here's your awesome PHP spec! Just make sure any new version you release matches the spec okay?
PHP developers: You're not the boss of me. [changes every function in PHP to be slightly different]
<|eoopr|><|sor|>The spec doesn't cover the standard library or any of the funky functions.<|eor|><|sor|>[deleted]<|eor|><|sor|>That's not what a spec is.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | merreborn | cjedxi8 | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>You'd think at some point along the way the Facebook devs would have realized they should just use a better language rather than trying to save a sinking ship.<|eor|><|sor|>Unfortunately at this point they probably can't. Whatever else you can say about Facebook, they're not stupid. And they're not the type of company to engage in massive CompSci research projects solely for the hell of it. They've obviously decided that hiring an army of PhDs to write saner runtimes for PHP and MySQL is less expensive than trying to rewrite their huge codebase and retool their gargantuan infrastructure.<|eor|><|sor|>The team that wrote the initial version of hip hop was actually very small. Writing php interpreter is easier than rewriting Facebook<|eor|><|sor|>Which is really really sad. How complicated does Facebook need to be really? It has maybe ten behaviors?<|eor|><|sor|>Web applications that serve hundreds of millions of users are complicated.
I mean, if you think facebook's simple, take a look at twitter. It only has one feature, sending 140 character messages. How hard could that be?
Truth is: really hard when you have to send over 100,000 messages per second.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | HookahComputer | cjhicut | <|sols|><|sot|>A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language.<|eot|><|sol|>http://www.theregister.co.uk/2014/08/01/php_draft_specification/<|eol|><|sor|>I laughed out loud reading the specification for the application of prefix ++/-- to empty strings. <|eor|><|sor|>For the lazy:
>For a prefix -- operator used with an operand whose value is an empty string, the side effect is that the operand's type is changed to int, the operand's value is set to zero, and that value is decremented by 1. The result is the value of the operand after it has been incremented.
>For a prefix ++ operator used with an operand whose value is an empty string, the side effect is that the operand's value is changed to the string "1". The type of the operand is unchanged. The result is the new value of the operand.
<|eor|><|sor|>The rest of that section is pretty good too:
> For a prefix -- or ++ operator used with a numeric string, the numeric string is treated as the corresponding int or float value.
> For a prefix -- operator used with a non-numeric string-valued operand, there is no side effect, and the result is the operand's value.
> For a non-numeric string-valued operand that contains only alphanumeric characters, for a prefix ++ operator, the operand is considered to be a pseudo-base-36 number (i.e., with digits 09 followed by AZ or az) in which letter case is ignored for value purposes. The right-most digit is incremented by 1. For the digits 08, that means going to 19. For the letters "A""Y" (or "a""y"), that means going to "B""Z" (or "b""z"). For the digit 9, the digit becomes 0, and the carry is added to the next left-most digit, and so on. For the digit "Z" (or "z"), the resulting string has an extra digit "A" (or "a") appended. For example, when incrementing, "a" -> "b", "X" -> "AA", "AA" -> "AB", "F29" -> "F30", "FZ9" -> "GA0", and "ZZ9" -> "AAA0". A digit position containing a number wraps modulo-10, while a digit position containing a letter wraps modulo-26.
> For a non-numeric string-valued operand that contains any non-alphanumeric characters, for a prefix ++ operator, all characters up to and including the right-most non-alphanumeric character is passed through to the resulting string, unchanged. Characters to the right of that right-most non-alphanumeric character are treated like a non-numeric string-valued operand that contains only alphanumeric characters, except that the resulting string will not be extended. Instead, a digit position containing a number wraps modulo-10, while a digit position containing a letter wraps modulo-26.
On the one hand, kudos for the clear, concise explanation of some very complicated behavior. On the other hand, WTF?!<|eor|><|sor|>It's what Perl does. (I wish I wasn't Perl as a defence)<|eor|><|sor|>"The autodecrement operator is not magical"
--Larry Wall, after describing the magical autoincrement operator<|eor|><|eols|><|endoftext|> | 5 |
lolphp | LPanthers | 21z2n6 | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 48 |
lolphp | Capaj | cgi0o6o | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eor|><|sor|>From the comments on that article:
>'PHP is the Winchester Mystery House of programming languages. If PHP were a house, the master bedroom would have 4 extra doors leading off it. One would be labeled "womenstoilet" and have a regular porcelain potty, the second would be labeled "washroom_mens" and just have a urinal ($DEITY help you if you're a man and need to go #2, because womenstoilet($male) is not permitted). The third would be "bathroom" and would contain a bath. Which is filled with kitty litter, because someone remembered that the family living there might have a cat which needs a toilet too. This is despite there being a perfectly good litter box in the back hallway, which the person who filled the bathtub was not aware of. The fourth door is a tiny unlabeled hatchway hidden behind a bookcase. When you open it there's a small shrine dedicated to the builders of the house, set in the middle of an otherwise unusable 1000sq.ft. room.<|eor|><|eoss|><|endoftext|> | 77 |
lolphp | TheBananaKing | cghsvao | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eor|><|eoss|><|endoftext|> | 68 |
lolphp | vytah | cghv65h | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>Easiest to understand reason? [You'll get paid less.](http://bpodgursky.com/2013/08/21/average-income-per-programming-language/)
I'll explain another reason with an analogy: imagine you want to be an architect, but before you do, you need to learn how to build walls. Which would you choose: bricks that are light, but each is of a different size, or heavy bricks of uniform sizes?
You may get quite good in building walls with non-uniform bricks, but they will always look ugly and they will often fall apart. You'll build your first toy pseudo-wall quickly, but building a full-size wall will require complex tricks to circumvent shortcomings of the bricks. Besides, when you finally move onto learning how to become an architect, you realise uniform bricks make architecture easier and all your tricks to lay uneven bricks are worthless.<|eor|><|eoss|><|endoftext|> | 50 |
lolphp | hahainternet | cghuelz | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>It does nothing better than anything else. It has bizarre rules, inconsistent naming, impossible exceptions and there's no justification for it.
Perl or Python. Go or Rust. Haskell or Erlang. Those are acceptable choices. There's also .NET if you don't really like yourself.<|eor|><|sor|>The one thing PHP does better than everything else is coming virtually preinstalled and working out of the box on almost everything
$2 hosting account, $400 dedicated server, Debian based Linux, red hat based Linux, OSX, windows, it's gonna run fine first time every time.
<|eor|><|sor|>> The one thing PHP does better than everything else is coming virtually preinstalled and working out of the box on almost everything
Soooorta. You're right it's ubiquitous, but php.ini settings = developer pain.<|eor|><|eoss|><|endoftext|> | 32 |
lolphp | Serialk | cgm5wae | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eor|><|sor|>Best read [alongside a rebuttal](http://forums.devshed.com/php-development-5/php-fractal-bad-design-hardly-929746.html). Most complaints are from those who don't understand/enjoy loose-typing.<|eor|><|sor|>Love it.
"It's purely a web language, and nothing else. Websites don't need threads, because if they take longer than a second to run they've failed. Again, fundamental lack of understanding."
Yeah, thank you for your input, you seem to know exactly what you're talking about.<|eor|><|eoss|><|endoftext|> | 25 |
lolphp | hahainternet | cghtes2 | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>It does nothing better than anything else. It has bizarre rules, inconsistent naming, impossible exceptions and there's no justification for it.
Perl or Python. Go or Rust. Haskell or Erlang. Those are acceptable choices. There's also .NET if you don't really like yourself.<|eor|><|eoss|><|endoftext|> | 22 |
lolphp | allthediamonds | cgi1xon | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>PHP doesn't suck. It's the people working on PHP that suck.<|eor|><|sor|>There's some truth to this. PHP does suck, but people working on PHP suck as well. Keep in mind that if you work on a PHP shop, most of the time you'll be working with people whose incompetence made them choose PHP.
It's like "building a house with gum doesn't suck, it's the builders who suck". Well, yeah, that too.<|eor|><|eoss|><|endoftext|> | 21 |
lolphp | _vec_ | cgmb0fg | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eor|><|sor|>Best read [alongside a rebuttal](http://forums.devshed.com/php-development-5/php-fractal-bad-design-hardly-929746.html). Most complaints are from those who don't understand/enjoy loose-typing.<|eor|><|sor|>Love it.
"It's purely a web language, and nothing else. Websites don't need threads, because if they take longer than a second to run they've failed. Again, fundamental lack of understanding."
Yeah, thank you for your input, you seem to know exactly what you're talking about.<|eor|><|sor|>I actually find this thread very valuable. For anyone who hasn't clicked through, the author of the original piece shows up to defend his points, and he and the author of the rebuttal go several rounds of (mostly) civil debate. The author of the rebuttal comes across as reasonably smart and experienced, but there's several places where he reveals some very bad assumptions.
* He assumes the CGI model is the only way to run a webserver. There's a quote about websites not needing threads and some talk of why "/index.php?post=wharblgarbl" is a bad URL that reveal that he's can't imagine a way to run a site that isn't one-process-per request and one-file-per-url.
* He doesn't seem to understand that there are options for handling fatal errors besides dumping the stack trace into the template and the white screen of death. He talks about logs in a way that reveals he's never used a system that produced useful ones, and because PHP's exception/error system is scary he assumes exceptions are inherently scary and should be avoided.
* He conflates scoping, variable declaration, type coercion, and truthiness. There's a long discussion, in particular, about `strpos` in PHP that some languages sidestep entirely by treating `0` as truthy.
This mirrors my experience talking to real-world PHP fans. They're not bad programmers and they don't have bad taste, they just lack the context to understand why what they're looking at is bad.<|eor|><|eoss|><|endoftext|> | 21 |
lolphp | PasswordIsntHAMSTER | cgi6eif | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>It does nothing better than anything else. It has bizarre rules, inconsistent naming, impossible exceptions and there's no justification for it.
Perl or Python. Go or Rust. Haskell or Erlang. Those are acceptable choices. There's also .NET if you don't really like yourself.<|eor|><|sor|>Why the .NET hate? I'd much rather use that than the JVM.<|eor|><|eoss|><|endoftext|> | 20 |
lolphp | CornPlanter | cghvgfx | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>It does nothing better than anything else. It has bizarre rules, inconsistent naming, impossible exceptions and there's no justification for it.
Perl or Python. Go or Rust. Haskell or Erlang. Those are acceptable choices. There's also .NET if you don't really like yourself.<|eor|><|sor|>The one thing PHP does better than everything else is coming virtually preinstalled and working out of the box on almost everything
$2 hosting account, $400 dedicated server, Debian based Linux, red hat based Linux, OSX, windows, it's gonna run fine first time every time.
<|eor|><|sor|>> The one thing PHP does better than everything else is coming virtually preinstalled and working out of the box on almost everything
Soooorta. You're right it's ubiquitous, but php.ini settings = developer pain.<|eor|><|sor|>And extensions aren't always consistent either, but it's not BAD (also, .ini over rideable at runtime helps for SOME)
I'm just saying, take the most simple python or go or ruby website - like flask or bottle - and write down the steps necessary to deploy it. Think about the wsgi connections, about getting dependencies and modules setup, virtenvs or app proxies. Pip or easy_install anything?
PHP? Drop PHP files in web root. Done.
<|eor|><|sor|>> 'm just saying, take the most simple python or go or ruby website - like flask or bottle - and write down the steps necessary to deploy it. Think about the wsgi connections, about getting dependencies and modules setup, virtenvs or app proxies. Pip or easy_install anything?
>
> PHP? Drop PHP files in web root. Done.
Soooooorta. Again that can be true with a bunch of caveats, but let me deploy a Perl project for you:
* install perlbrew*
perlbrew install perl-5.19.10
* a short time later *
perlbrew install-cpanm
perlbrew lib create perl-5.19.10@myproject
perlbrew use perl-5.19.10@myproject
cd /path/to/my/project
cpanm --installdeps .
It's really not that complex to do some of this. I can straight run a HTTPd and proxy Nginx through or go wherever I like from here and it's pretty effective.
Yes, PHP can in some situations be faster, but that speed brings almost nothing other than a few minutes of saving three or four times in the lifetime of a product.<|eor|><|sor|>You can install nginx
I can install nginx
Both of us can probably script it in our sleep, and if you're like me you've already got hundreds of VMs floating around to install it in and you know what nginx is and it's going to already be installed somewhere.
But entry level "I need a website and I have a $20 budget", no VMs around, running windows, no servers in sight? SOL.
That's my only point. That's why PHP has the market share it has, and that's why it will continue to have that market share. <|eor|><|sor|>PHP allows people with $20 budget, questionable machine setups and no programming experience to make messed up, bug ridden, laughable security websites that sorta work.
Well it can be viewed as a positive... I mean there's certainly a positive side to it, right...<|eor|><|eoss|><|endoftext|> | 19 |
lolphp | EvilTerran | cgi5iwn | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>Easiest to understand reason? [You'll get paid less.](http://bpodgursky.com/2013/08/21/average-income-per-programming-language/)
I'll explain another reason with an analogy: imagine you want to be an architect, but before you do, you need to learn how to build walls. Which would you choose: bricks that are light, but each is of a different size, or heavy bricks of uniform sizes?
You may get quite good in building walls with non-uniform bricks, but they will always look ugly and they will often fall apart. You'll build your first toy pseudo-wall quickly, but building a full-size wall will require complex tricks to circumvent shortcomings of the bricks. Besides, when you finally move onto learning how to become an architect, you realise uniform bricks make architecture easier and all your tricks to lay uneven bricks are worthless.<|eor|><|sor|>Wow those rankings are weird.<|eor|><|sor|>I'm not sure about those rankings as well, but anecdotal evidence I know also supports the theory that PHP programmers are on average paid less.<|eor|><|sor|>[deleted]<|eor|><|sor|>I think people would cope with lower pay in order to be able to program in Haskell/PHP. On the ActionScript thing, obscure languages probably get better pay.<|eor|><|sor|>I suspect Haskell scores so low because most folks using it for a living are academics, not in industry.<|eor|><|eoss|><|endoftext|> | 18 |
lolphp | hahainternet | cghvztl | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>It does nothing better than anything else. It has bizarre rules, inconsistent naming, impossible exceptions and there's no justification for it.
Perl or Python. Go or Rust. Haskell or Erlang. Those are acceptable choices. There's also .NET if you don't really like yourself.<|eor|><|sor|>The one thing PHP does better than everything else is coming virtually preinstalled and working out of the box on almost everything
$2 hosting account, $400 dedicated server, Debian based Linux, red hat based Linux, OSX, windows, it's gonna run fine first time every time.
<|eor|><|sor|>> The one thing PHP does better than everything else is coming virtually preinstalled and working out of the box on almost everything
Soooorta. You're right it's ubiquitous, but php.ini settings = developer pain.<|eor|><|sor|>And extensions aren't always consistent either, but it's not BAD (also, .ini over rideable at runtime helps for SOME)
I'm just saying, take the most simple python or go or ruby website - like flask or bottle - and write down the steps necessary to deploy it. Think about the wsgi connections, about getting dependencies and modules setup, virtenvs or app proxies. Pip or easy_install anything?
PHP? Drop PHP files in web root. Done.
<|eor|><|sor|>> 'm just saying, take the most simple python or go or ruby website - like flask or bottle - and write down the steps necessary to deploy it. Think about the wsgi connections, about getting dependencies and modules setup, virtenvs or app proxies. Pip or easy_install anything?
>
> PHP? Drop PHP files in web root. Done.
Soooooorta. Again that can be true with a bunch of caveats, but let me deploy a Perl project for you:
* install perlbrew*
perlbrew install perl-5.19.10
* a short time later *
perlbrew install-cpanm
perlbrew lib create perl-5.19.10@myproject
perlbrew use perl-5.19.10@myproject
cd /path/to/my/project
cpanm --installdeps .
It's really not that complex to do some of this. I can straight run a HTTPd and proxy Nginx through or go wherever I like from here and it's pretty effective.
Yes, PHP can in some situations be faster, but that speed brings almost nothing other than a few minutes of saving three or four times in the lifetime of a product.<|eor|><|sor|>You can install nginx
I can install nginx
Both of us can probably script it in our sleep, and if you're like me you've already got hundreds of VMs floating around to install it in and you know what nginx is and it's going to already be installed somewhere.
But entry level "I need a website and I have a $20 budget", no VMs around, running windows, no servers in sight? SOL.
That's my only point. That's why PHP has the market share it has, and that's why it will continue to have that market share. <|eor|><|sor|>PHP allows people with $20 budget, questionable machine setups and no programming experience to make messed up, bug ridden, laughable security websites that sorta work.
Well it can be viewed as a positive... I mean there's certainly a positive side to it, right...<|eor|><|sor|>> PHP allows people with $20 budget, questionable machine setups and no programming experience to make messed up, bug ridden, laughable security websites that sorta work.
You are absolutely correct. You can wire your house with a screwdriver and a knife. That does not mean that it is something you should do. PHP is that.<|eor|><|eoss|><|endoftext|> | 18 |
lolphp | PasswordIsntHAMSTER | cgi7040 | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>It does nothing better than anything else. It has bizarre rules, inconsistent naming, impossible exceptions and there's no justification for it.
Perl or Python. Go or Rust. Haskell or Erlang. Those are acceptable choices. There's also .NET if you don't really like yourself.<|eor|><|sor|>Why the .NET hate? I'd much rather use that than the JVM.<|eor|><|sor|>.NET's languages are fine. Unfortunately it's run by a convicted monopolist and is poorly supported elsewhere.
Microsoft is dying, their cloud solutions are dying, their office solutions are dying. It's only a matter of time until they try to use .NET as a weapon.
Java is also in a poor situation thanks to Oracle, but there's fuck all they can do about existing JREs even if they win against Google, which seems unlikely.
Java truly does run everywhere.<|eor|><|sor|>>Microsoft is dying
fullretard.jpg<|eor|><|eoss|><|endoftext|> | 16 |
lolphp | Razakel | cgieu36 | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>PHP is like giving a baby a nailgun. It *can* be used properly, but chances are you'll end up with a bloody mess.<|eor|><|eoss|><|endoftext|> | 15 |
lolphp | allthediamonds | cgi2n4b | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>PHP doesn't suck. It's the people working on PHP that suck.<|eor|><|sor|>There's some truth to this. PHP does suck, but people working on PHP suck as well. Keep in mind that if you work on a PHP shop, most of the time you'll be working with people whose incompetence made them choose PHP.
It's like "building a house with gum doesn't suck, it's the builders who suck". Well, yeah, that too.<|eor|><|sor|>I know there are some poor design decisions in PHP but still the main reason why PHP sucks is because developers working with it suck. It is very easy to learn unlike other languages so this benefit of PHP somehow also becomes its drawback as every Tom, Dick and Harry knows how to program in PHP.
Some of the largest websites are developed in PHP such as Facebook, Wikipedia, Flickr, SourceForge etc.<|eor|><|sor|>I don't see why people say PHP is "very easy to learn". Sure, it's very easy to hack a hardly-functional buggy-as-hell application because PHP will rather churn along with nonsensical results than halt on error. But learning its arcane, needlessly C-like syntax and its bafflingly inconsistent function names? That's not easy at all.
On the "some of the largest websites are developed in PHP" front: first of all, "everybody poops" is not an argument; second of all, that argument doesn't particularly play well: Facebook had to build an entire virtual machine and a programming language to mitigate PHP's problems, and Wikipedia has to ask for millions of dollars per year to support a website which could perfectly be served as plain, static pages.<|eor|><|eoss|><|endoftext|> | 14 |
lolphp | PasswordIsntHAMSTER | cgi6dwz | <|soss|><|sot|>I'm a newbie and I'm currently learning PHP. Tell me why PHP sucks dick ?<|eot|><|sost|><|eost|><|sor|>Easiest to understand reason? [You'll get paid less.](http://bpodgursky.com/2013/08/21/average-income-per-programming-language/)
I'll explain another reason with an analogy: imagine you want to be an architect, but before you do, you need to learn how to build walls. Which would you choose: bricks that are light, but each is of a different size, or heavy bricks of uniform sizes?
You may get quite good in building walls with non-uniform bricks, but they will always look ugly and they will often fall apart. You'll build your first toy pseudo-wall quickly, but building a full-size wall will require complex tricks to circumvent shortcomings of the bricks. Besides, when you finally move onto learning how to become an architect, you realise uniform bricks make architecture easier and all your tricks to lay uneven bricks are worthless.<|eor|><|sor|>Wow those rankings are weird.<|eor|><|sor|>I'm not sure about those rankings as well, but anecdotal evidence I know also supports the theory that PHP programmers are on average paid less.<|eor|><|sor|>[deleted]<|eor|><|sor|>I think people would cope with lower pay in order to be able to program in Haskell/PHP. On the ActionScript thing, obscure languages probably get better pay.<|eor|><|sor|>Academic languages have a handicap because Ph. D students are paid shit.<|eor|><|eoss|><|endoftext|> | 14 |
lolphp | RedWingate | t8k06 | <|sols|><|sot|>Stop calling them developers ...<|eot|><|sol|>http://i.imgur.com/TeQZQ.jpg<|eol|><|eols|><|endoftext|> | 45 |
lolphp | StrangeWill | c4kik6y | <|sols|><|sot|>Stop calling them developers ...<|eot|><|sol|>http://i.imgur.com/TeQZQ.jpg<|eol|><|sor|>Lots of people make a living doing PHP development, therefore, they are developers. I personally think JavaScript is the crappiest language programmers have to deal with, but I'm not about to strip away "developer" from JS coders' job titles.<|eor|><|sor|>>Lots of people make a living doing PHP development, therefore, they are developers.
Yeah, I prefer to call those _victims_.<|eor|><|eols|><|endoftext|> | 16 |
lolphp | droidballoon | c4kijlc | <|sols|><|sot|>Stop calling them developers ...<|eot|><|sol|>http://i.imgur.com/TeQZQ.jpg<|eol|><|sor|>Lots of people make a living doing PHP development, therefore, they are developers. I personally think JavaScript is the crappiest language programmers have to deal with, but I'm not about to strip away "developer" from JS coders' job titles.<|eor|><|sor|>This is rather a critique aimed at the people developing PHP itself, not developing *in* PHP.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | Takeoded | z9mp36 | <|soss|><|sot|>socket_set_block() accepts sockets not streams, and socket_set_blocking() accepts streams not sockets.<|eot|><|sost|>compare [socket_set_block()](https://www.php.net/manual/en/function.socket-set-block) vs [socket_set_blocking()](https://www.php.net/manual/en/function.socket-set-blocking) , i just used the wrong one in a project (-:
>PHP Fatal error: Uncaught TypeError: socket_set_blocking(): Argument #1 ($stream) must be of type resource, Socket given
socket_set_blocking() complaining about being given a Socket is pretty funny<|eost|><|eoss|><|endoftext|> | 47 |
lolphp | modestlife | iyhn2kr | <|soss|><|sot|>socket_set_block() accepts sockets not streams, and socket_set_blocking() accepts streams not sockets.<|eot|><|sost|>compare [socket_set_block()](https://www.php.net/manual/en/function.socket-set-block) vs [socket_set_blocking()](https://www.php.net/manual/en/function.socket-set-blocking) , i just used the wrong one in a project (-:
>PHP Fatal error: Uncaught TypeError: socket_set_blocking(): Argument #1 ($stream) must be of type resource, Socket given
socket_set_blocking() complaining about being given a Socket is pretty funny<|eost|><|sor|>I think it's because socket and streams were both working on resources before the `Socket` class was introduced in PHP 8.
- `socket_set_blocking`: This function is an alias of: `stream_set_blocking()`
- `socket_set_block`: Changelog 8.0.0: `socket` is a `Socket` instance now; previously, it was a resource
Don't know if it was deprecated though; can't find anything. Should probably be fixed in some way because they're not interchangeable anymore.<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | barubary | cvpj25 | <|soss|><|sot|>Problems with the official operator precedence table<|eot|><|sost|>PHP has operators. These operators have a priority called [operator precedence](https://www.php.net/manual/en/language.operators.precedence.php), as explained in the official documentation. All of this is pretty standard.
However, the accompanying table is full of lies and omissions:
> **Operator Precedence**
>
> Associativity Operators Additional Information
> ------------------------------------------------------------------------------------------------------------------
> non-associative clone new clone and new
> left [ array()
> right ** arithmetic
> right ++ -- ~ (int) (float) (string) (array) (object) (bool) @ types and increment/decrement
> non-associative instanceof types
> right ! logical
> left * / % arithmetic
> [...]
- Omission: The table does not list the syntax of each operator and how many operands it takes. There is only a single entry for `++` and `--`; the different prefix/postfix forms are not mentioned.
- Omission: `@` is tucked away at the end of the list of casts. There is no "additional information" link for it.
- Lie: Several unary operators list an associativity. This makes no sense; associativity tells you how `A ? B ? C` is parsed (for some infix operator `?`): `(A ? B) ? C` or `A ? (B ? C)`. Unary operators only have a single operand, so there is no ambiguity in how they associate.
- Lie: `**` is listed as having a higher precedence than `++` / `--`. This is simply not true; `++` binds tighter than `**`, in either prefix or postfix form.
- Lie: `clone` is listed as having a higher precedence than `[`. This is not true: `clone $x[0]` parses as `clone ($x[0])`, not `(clone $x)[0]`.
- Lie: `instanceof` is listed as *non-associative*, meaning `X instanceof Y instanceof Z` should be a syntax error. It isn't.
- Omission: The assignment operators get a normal entry in the precedence table. Only a short note at the very end of the page indicates that something weird might be going on:
> Although `=` has a lower precedence than most other operators, PHP will still allow expressions similar to the following: `if (!$a = foo())`, in which case the return value of `foo()` is put into `$a`.
What's actually going on is that `=` (and friends: `+=`, `-=`, ...) have a different left-precedence and right-precedence. Their right-precedence is as indicated (i.e. the right-hand side of assignments is parsed as in most other C-based languages), but their left-precedence is very high, even higher than `clone` or `new`: `A + !B = !C + D` parses as `A + !(B = ((!C) + D))`.
- Omission: The table does not explain how `(string) ! $x instanceof C` should be parsed. The issue here is that `!` has the lowest precedence, `instanceof` has a medium precedence, and `(string)` has the highest precedence. In isolation, `(string) $x instanceof C` should therefore be parsed as `((string)$x) instanceof C`, and `! $x instanceof C` as `!($x instanceof C)`. But what is supposed to happen if you stack them in this order? Does `instanceof C` grab the `$x` operand because it has higher precedence than `!`? Or does `(string)` protect its whole operand because it has higher precedence than `instanceof`, giving `((string)!$x) instanceof C`?
---
*Edit:*
- Omission: Unary `&` (for creating references) is not listed at all. The `&` entry in the table (near the middle, left associative) only fits infix `&` (bitwise AND).
- Omission: `->` and `::` are not listed. I assume they should be in the same row as `[`, but who knows.<|eost|><|eoss|><|endoftext|> | 50 |
lolphp | C0c04l4 | ey67hjs | <|soss|><|sot|>Problems with the official operator precedence table<|eot|><|sost|>PHP has operators. These operators have a priority called [operator precedence](https://www.php.net/manual/en/language.operators.precedence.php), as explained in the official documentation. All of this is pretty standard.
However, the accompanying table is full of lies and omissions:
> **Operator Precedence**
>
> Associativity Operators Additional Information
> ------------------------------------------------------------------------------------------------------------------
> non-associative clone new clone and new
> left [ array()
> right ** arithmetic
> right ++ -- ~ (int) (float) (string) (array) (object) (bool) @ types and increment/decrement
> non-associative instanceof types
> right ! logical
> left * / % arithmetic
> [...]
- Omission: The table does not list the syntax of each operator and how many operands it takes. There is only a single entry for `++` and `--`; the different prefix/postfix forms are not mentioned.
- Omission: `@` is tucked away at the end of the list of casts. There is no "additional information" link for it.
- Lie: Several unary operators list an associativity. This makes no sense; associativity tells you how `A ? B ? C` is parsed (for some infix operator `?`): `(A ? B) ? C` or `A ? (B ? C)`. Unary operators only have a single operand, so there is no ambiguity in how they associate.
- Lie: `**` is listed as having a higher precedence than `++` / `--`. This is simply not true; `++` binds tighter than `**`, in either prefix or postfix form.
- Lie: `clone` is listed as having a higher precedence than `[`. This is not true: `clone $x[0]` parses as `clone ($x[0])`, not `(clone $x)[0]`.
- Lie: `instanceof` is listed as *non-associative*, meaning `X instanceof Y instanceof Z` should be a syntax error. It isn't.
- Omission: The assignment operators get a normal entry in the precedence table. Only a short note at the very end of the page indicates that something weird might be going on:
> Although `=` has a lower precedence than most other operators, PHP will still allow expressions similar to the following: `if (!$a = foo())`, in which case the return value of `foo()` is put into `$a`.
What's actually going on is that `=` (and friends: `+=`, `-=`, ...) have a different left-precedence and right-precedence. Their right-precedence is as indicated (i.e. the right-hand side of assignments is parsed as in most other C-based languages), but their left-precedence is very high, even higher than `clone` or `new`: `A + !B = !C + D` parses as `A + !(B = ((!C) + D))`.
- Omission: The table does not explain how `(string) ! $x instanceof C` should be parsed. The issue here is that `!` has the lowest precedence, `instanceof` has a medium precedence, and `(string)` has the highest precedence. In isolation, `(string) $x instanceof C` should therefore be parsed as `((string)$x) instanceof C`, and `! $x instanceof C` as `!($x instanceof C)`. But what is supposed to happen if you stack them in this order? Does `instanceof C` grab the `$x` operand because it has higher precedence than `!`? Or does `(string)` protect its whole operand because it has higher precedence than `instanceof`, giving `((string)!$x) instanceof C`?
---
*Edit:*
- Omission: Unary `&` (for creating references) is not listed at all. The `&` entry in the table (near the middle, left associative) only fits infix `&` (bitwise AND).
- Omission: `->` and `::` are not listed. I assume they should be in the same row as `[`, but who knows.<|eost|><|sor|>It would be great if you could modify the documentation to make all the writing you did for this post useful to the world!<|eor|><|eoss|><|endoftext|> | 23 |
lolphp | C0c04l4 | ey7bman | <|soss|><|sot|>Problems with the official operator precedence table<|eot|><|sost|>PHP has operators. These operators have a priority called [operator precedence](https://www.php.net/manual/en/language.operators.precedence.php), as explained in the official documentation. All of this is pretty standard.
However, the accompanying table is full of lies and omissions:
> **Operator Precedence**
>
> Associativity Operators Additional Information
> ------------------------------------------------------------------------------------------------------------------
> non-associative clone new clone and new
> left [ array()
> right ** arithmetic
> right ++ -- ~ (int) (float) (string) (array) (object) (bool) @ types and increment/decrement
> non-associative instanceof types
> right ! logical
> left * / % arithmetic
> [...]
- Omission: The table does not list the syntax of each operator and how many operands it takes. There is only a single entry for `++` and `--`; the different prefix/postfix forms are not mentioned.
- Omission: `@` is tucked away at the end of the list of casts. There is no "additional information" link for it.
- Lie: Several unary operators list an associativity. This makes no sense; associativity tells you how `A ? B ? C` is parsed (for some infix operator `?`): `(A ? B) ? C` or `A ? (B ? C)`. Unary operators only have a single operand, so there is no ambiguity in how they associate.
- Lie: `**` is listed as having a higher precedence than `++` / `--`. This is simply not true; `++` binds tighter than `**`, in either prefix or postfix form.
- Lie: `clone` is listed as having a higher precedence than `[`. This is not true: `clone $x[0]` parses as `clone ($x[0])`, not `(clone $x)[0]`.
- Lie: `instanceof` is listed as *non-associative*, meaning `X instanceof Y instanceof Z` should be a syntax error. It isn't.
- Omission: The assignment operators get a normal entry in the precedence table. Only a short note at the very end of the page indicates that something weird might be going on:
> Although `=` has a lower precedence than most other operators, PHP will still allow expressions similar to the following: `if (!$a = foo())`, in which case the return value of `foo()` is put into `$a`.
What's actually going on is that `=` (and friends: `+=`, `-=`, ...) have a different left-precedence and right-precedence. Their right-precedence is as indicated (i.e. the right-hand side of assignments is parsed as in most other C-based languages), but their left-precedence is very high, even higher than `clone` or `new`: `A + !B = !C + D` parses as `A + !(B = ((!C) + D))`.
- Omission: The table does not explain how `(string) ! $x instanceof C` should be parsed. The issue here is that `!` has the lowest precedence, `instanceof` has a medium precedence, and `(string)` has the highest precedence. In isolation, `(string) $x instanceof C` should therefore be parsed as `((string)$x) instanceof C`, and `! $x instanceof C` as `!($x instanceof C)`. But what is supposed to happen if you stack them in this order? Does `instanceof C` grab the `$x` operand because it has higher precedence than `!`? Or does `(string)` protect its whole operand because it has higher precedence than `instanceof`, giving `((string)!$x) instanceof C`?
---
*Edit:*
- Omission: Unary `&` (for creating references) is not listed at all. The `&` entry in the table (near the middle, left associative) only fits infix `&` (bitwise AND).
- Omission: `->` and `::` are not listed. I assume they should be in the same row as `[`, but who knows.<|eost|><|sor|>It would be great if you could modify the documentation to make all the writing you did for this post useful to the world!<|eor|><|soopr|>I don't think you understand the point of this subreddit. I'm not here to improve PHP.<|eoopr|><|sor|>I think it's a shame to spend time redacting a comprehensive reddit post to make fun of the doc instead of actually doing something useful like fixing the doc... There is a web editor, it's quite easy to do in fact.<|eor|><|eoss|><|endoftext|> | 13 |
lolphp | the_alias_of_andrea | ey62s84 | <|soss|><|sot|>Problems with the official operator precedence table<|eot|><|sost|>PHP has operators. These operators have a priority called [operator precedence](https://www.php.net/manual/en/language.operators.precedence.php), as explained in the official documentation. All of this is pretty standard.
However, the accompanying table is full of lies and omissions:
> **Operator Precedence**
>
> Associativity Operators Additional Information
> ------------------------------------------------------------------------------------------------------------------
> non-associative clone new clone and new
> left [ array()
> right ** arithmetic
> right ++ -- ~ (int) (float) (string) (array) (object) (bool) @ types and increment/decrement
> non-associative instanceof types
> right ! logical
> left * / % arithmetic
> [...]
- Omission: The table does not list the syntax of each operator and how many operands it takes. There is only a single entry for `++` and `--`; the different prefix/postfix forms are not mentioned.
- Omission: `@` is tucked away at the end of the list of casts. There is no "additional information" link for it.
- Lie: Several unary operators list an associativity. This makes no sense; associativity tells you how `A ? B ? C` is parsed (for some infix operator `?`): `(A ? B) ? C` or `A ? (B ? C)`. Unary operators only have a single operand, so there is no ambiguity in how they associate.
- Lie: `**` is listed as having a higher precedence than `++` / `--`. This is simply not true; `++` binds tighter than `**`, in either prefix or postfix form.
- Lie: `clone` is listed as having a higher precedence than `[`. This is not true: `clone $x[0]` parses as `clone ($x[0])`, not `(clone $x)[0]`.
- Lie: `instanceof` is listed as *non-associative*, meaning `X instanceof Y instanceof Z` should be a syntax error. It isn't.
- Omission: The assignment operators get a normal entry in the precedence table. Only a short note at the very end of the page indicates that something weird might be going on:
> Although `=` has a lower precedence than most other operators, PHP will still allow expressions similar to the following: `if (!$a = foo())`, in which case the return value of `foo()` is put into `$a`.
What's actually going on is that `=` (and friends: `+=`, `-=`, ...) have a different left-precedence and right-precedence. Their right-precedence is as indicated (i.e. the right-hand side of assignments is parsed as in most other C-based languages), but their left-precedence is very high, even higher than `clone` or `new`: `A + !B = !C + D` parses as `A + !(B = ((!C) + D))`.
- Omission: The table does not explain how `(string) ! $x instanceof C` should be parsed. The issue here is that `!` has the lowest precedence, `instanceof` has a medium precedence, and `(string)` has the highest precedence. In isolation, `(string) $x instanceof C` should therefore be parsed as `((string)$x) instanceof C`, and `! $x instanceof C` as `!($x instanceof C)`. But what is supposed to happen if you stack them in this order? Does `instanceof C` grab the `$x` operand because it has higher precedence than `!`? Or does `(string)` protect its whole operand because it has higher precedence than `instanceof`, giving `((string)!$x) instanceof C`?
---
*Edit:*
- Omission: Unary `&` (for creating references) is not listed at all. The `&` entry in the table (near the middle, left associative) only fits infix `&` (bitwise AND).
- Omission: `->` and `::` are not listed. I assume they should be in the same row as `[`, but who knows.<|eost|><|sor|>Oof.
I wonder if some of these were true in PHP 5 and nobody thought to update for the significant parsing changes in PHP 7.<|eor|><|eoss|><|endoftext|> | 11 |
lolphp | mikeputerbaugh | ey8arpx | <|soss|><|sot|>Problems with the official operator precedence table<|eot|><|sost|>PHP has operators. These operators have a priority called [operator precedence](https://www.php.net/manual/en/language.operators.precedence.php), as explained in the official documentation. All of this is pretty standard.
However, the accompanying table is full of lies and omissions:
> **Operator Precedence**
>
> Associativity Operators Additional Information
> ------------------------------------------------------------------------------------------------------------------
> non-associative clone new clone and new
> left [ array()
> right ** arithmetic
> right ++ -- ~ (int) (float) (string) (array) (object) (bool) @ types and increment/decrement
> non-associative instanceof types
> right ! logical
> left * / % arithmetic
> [...]
- Omission: The table does not list the syntax of each operator and how many operands it takes. There is only a single entry for `++` and `--`; the different prefix/postfix forms are not mentioned.
- Omission: `@` is tucked away at the end of the list of casts. There is no "additional information" link for it.
- Lie: Several unary operators list an associativity. This makes no sense; associativity tells you how `A ? B ? C` is parsed (for some infix operator `?`): `(A ? B) ? C` or `A ? (B ? C)`. Unary operators only have a single operand, so there is no ambiguity in how they associate.
- Lie: `**` is listed as having a higher precedence than `++` / `--`. This is simply not true; `++` binds tighter than `**`, in either prefix or postfix form.
- Lie: `clone` is listed as having a higher precedence than `[`. This is not true: `clone $x[0]` parses as `clone ($x[0])`, not `(clone $x)[0]`.
- Lie: `instanceof` is listed as *non-associative*, meaning `X instanceof Y instanceof Z` should be a syntax error. It isn't.
- Omission: The assignment operators get a normal entry in the precedence table. Only a short note at the very end of the page indicates that something weird might be going on:
> Although `=` has a lower precedence than most other operators, PHP will still allow expressions similar to the following: `if (!$a = foo())`, in which case the return value of `foo()` is put into `$a`.
What's actually going on is that `=` (and friends: `+=`, `-=`, ...) have a different left-precedence and right-precedence. Their right-precedence is as indicated (i.e. the right-hand side of assignments is parsed as in most other C-based languages), but their left-precedence is very high, even higher than `clone` or `new`: `A + !B = !C + D` parses as `A + !(B = ((!C) + D))`.
- Omission: The table does not explain how `(string) ! $x instanceof C` should be parsed. The issue here is that `!` has the lowest precedence, `instanceof` has a medium precedence, and `(string)` has the highest precedence. In isolation, `(string) $x instanceof C` should therefore be parsed as `((string)$x) instanceof C`, and `! $x instanceof C` as `!($x instanceof C)`. But what is supposed to happen if you stack them in this order? Does `instanceof C` grab the `$x` operand because it has higher precedence than `!`? Or does `(string)` protect its whole operand because it has higher precedence than `instanceof`, giving `((string)!$x) instanceof C`?
---
*Edit:*
- Omission: Unary `&` (for creating references) is not listed at all. The `&` entry in the table (near the middle, left associative) only fits infix `&` (bitwise AND).
- Omission: `->` and `::` are not listed. I assume they should be in the same row as `[`, but who knows.<|eost|><|sor|>It would be great if you could modify the documentation to make all the writing you did for this post useful to the world!<|eor|><|soopr|>I don't think you understand the point of this subreddit. I'm not here to improve PHP.<|eoopr|><|sor|>I think it's a shame to spend time redacting a comprehensive reddit post to make fun of the doc instead of actually doing something useful like fixing the doc... There is a web editor, it's quite easy to do in fact.<|eor|><|soopr|>> something useful like fixing the doc... There is a web editor, it's quite easy to do in fact.
OK, I'll bite. What do you think a "fixed" version of this documentation would look like?<|eoopr|><|sor|>You listed out 8 flaws in the documentation. A "fixed" version would have those flaws corrected.
Are you punking us? What's going on?<|eor|><|eoss|><|endoftext|> | 9 |
lolphp | barubary | ey8dnyj | <|soss|><|sot|>Problems with the official operator precedence table<|eot|><|sost|>PHP has operators. These operators have a priority called [operator precedence](https://www.php.net/manual/en/language.operators.precedence.php), as explained in the official documentation. All of this is pretty standard.
However, the accompanying table is full of lies and omissions:
> **Operator Precedence**
>
> Associativity Operators Additional Information
> ------------------------------------------------------------------------------------------------------------------
> non-associative clone new clone and new
> left [ array()
> right ** arithmetic
> right ++ -- ~ (int) (float) (string) (array) (object) (bool) @ types and increment/decrement
> non-associative instanceof types
> right ! logical
> left * / % arithmetic
> [...]
- Omission: The table does not list the syntax of each operator and how many operands it takes. There is only a single entry for `++` and `--`; the different prefix/postfix forms are not mentioned.
- Omission: `@` is tucked away at the end of the list of casts. There is no "additional information" link for it.
- Lie: Several unary operators list an associativity. This makes no sense; associativity tells you how `A ? B ? C` is parsed (for some infix operator `?`): `(A ? B) ? C` or `A ? (B ? C)`. Unary operators only have a single operand, so there is no ambiguity in how they associate.
- Lie: `**` is listed as having a higher precedence than `++` / `--`. This is simply not true; `++` binds tighter than `**`, in either prefix or postfix form.
- Lie: `clone` is listed as having a higher precedence than `[`. This is not true: `clone $x[0]` parses as `clone ($x[0])`, not `(clone $x)[0]`.
- Lie: `instanceof` is listed as *non-associative*, meaning `X instanceof Y instanceof Z` should be a syntax error. It isn't.
- Omission: The assignment operators get a normal entry in the precedence table. Only a short note at the very end of the page indicates that something weird might be going on:
> Although `=` has a lower precedence than most other operators, PHP will still allow expressions similar to the following: `if (!$a = foo())`, in which case the return value of `foo()` is put into `$a`.
What's actually going on is that `=` (and friends: `+=`, `-=`, ...) have a different left-precedence and right-precedence. Their right-precedence is as indicated (i.e. the right-hand side of assignments is parsed as in most other C-based languages), but their left-precedence is very high, even higher than `clone` or `new`: `A + !B = !C + D` parses as `A + !(B = ((!C) + D))`.
- Omission: The table does not explain how `(string) ! $x instanceof C` should be parsed. The issue here is that `!` has the lowest precedence, `instanceof` has a medium precedence, and `(string)` has the highest precedence. In isolation, `(string) $x instanceof C` should therefore be parsed as `((string)$x) instanceof C`, and `! $x instanceof C` as `!($x instanceof C)`. But what is supposed to happen if you stack them in this order? Does `instanceof C` grab the `$x` operand because it has higher precedence than `!`? Or does `(string)` protect its whole operand because it has higher precedence than `instanceof`, giving `((string)!$x) instanceof C`?
---
*Edit:*
- Omission: Unary `&` (for creating references) is not listed at all. The `&` entry in the table (near the middle, left associative) only fits infix `&` (bitwise AND).
- Omission: `->` and `::` are not listed. I assume they should be in the same row as `[`, but who knows.<|eost|><|sor|>It would be great if you could modify the documentation to make all the writing you did for this post useful to the world!<|eor|><|soopr|>I don't think you understand the point of this subreddit. I'm not here to improve PHP.<|eoopr|><|sor|>I think it's a shame to spend time redacting a comprehensive reddit post to make fun of the doc instead of actually doing something useful like fixing the doc... There is a web editor, it's quite easy to do in fact.<|eor|><|soopr|>> something useful like fixing the doc... There is a web editor, it's quite easy to do in fact.
OK, I'll bite. What do you think a "fixed" version of this documentation would look like?<|eoopr|><|sor|>You listed out 8 flaws in the documentation. A "fixed" version would have those flaws corrected.
Are you punking us? What's going on?<|eor|><|soopr|>> A "fixed" version would have those flaws corrected.
That's too vague. I'm looking for actual text I could actually put on that page.
I listed 1) discrepancies between the documentation and the observed behavior of my `php` executable (version 7.1.20) and 2) missing information / undocumented behavior.
To fix #1 I would need to know which behavior is considered correct, the documentation or the implementation (or neither?). What is authoritative? If the implementation is always correct, how do I derive a description of the behavior? If empirically, how do I test all corner cases to create a fully correct description? If I don't, the new "fixed" documentation may still be wrong, just in different places. (As always, finding bugs by testing is easy; proving correctness by testing is impossible.) Do I analyze the PHP source code? That may take me a while. In either case it would be a snapshot description of whatever version of PHP I'm looking at.
To fix #2 I don't know where to start. Where do I look up missing information if the reference documentation itself has holes?
Again, it's easy to point out flaws, but hard to write correct documentation yourself. I noticed the absence of e.g. information on how to parse `(string) ! $x instanceof Y` because I didn't understand how it works. I still don't know how it works (let alone how it is supposed to work). How do you expect me to come up with this information myself?
"*There is a web editor, it's quite easy to do in fact*" my ass.<|eoopr|><|eoss|><|endoftext|> | 9 |
lolphp | barubary | ey866qp | <|soss|><|sot|>Problems with the official operator precedence table<|eot|><|sost|>PHP has operators. These operators have a priority called [operator precedence](https://www.php.net/manual/en/language.operators.precedence.php), as explained in the official documentation. All of this is pretty standard.
However, the accompanying table is full of lies and omissions:
> **Operator Precedence**
>
> Associativity Operators Additional Information
> ------------------------------------------------------------------------------------------------------------------
> non-associative clone new clone and new
> left [ array()
> right ** arithmetic
> right ++ -- ~ (int) (float) (string) (array) (object) (bool) @ types and increment/decrement
> non-associative instanceof types
> right ! logical
> left * / % arithmetic
> [...]
- Omission: The table does not list the syntax of each operator and how many operands it takes. There is only a single entry for `++` and `--`; the different prefix/postfix forms are not mentioned.
- Omission: `@` is tucked away at the end of the list of casts. There is no "additional information" link for it.
- Lie: Several unary operators list an associativity. This makes no sense; associativity tells you how `A ? B ? C` is parsed (for some infix operator `?`): `(A ? B) ? C` or `A ? (B ? C)`. Unary operators only have a single operand, so there is no ambiguity in how they associate.
- Lie: `**` is listed as having a higher precedence than `++` / `--`. This is simply not true; `++` binds tighter than `**`, in either prefix or postfix form.
- Lie: `clone` is listed as having a higher precedence than `[`. This is not true: `clone $x[0]` parses as `clone ($x[0])`, not `(clone $x)[0]`.
- Lie: `instanceof` is listed as *non-associative*, meaning `X instanceof Y instanceof Z` should be a syntax error. It isn't.
- Omission: The assignment operators get a normal entry in the precedence table. Only a short note at the very end of the page indicates that something weird might be going on:
> Although `=` has a lower precedence than most other operators, PHP will still allow expressions similar to the following: `if (!$a = foo())`, in which case the return value of `foo()` is put into `$a`.
What's actually going on is that `=` (and friends: `+=`, `-=`, ...) have a different left-precedence and right-precedence. Their right-precedence is as indicated (i.e. the right-hand side of assignments is parsed as in most other C-based languages), but their left-precedence is very high, even higher than `clone` or `new`: `A + !B = !C + D` parses as `A + !(B = ((!C) + D))`.
- Omission: The table does not explain how `(string) ! $x instanceof C` should be parsed. The issue here is that `!` has the lowest precedence, `instanceof` has a medium precedence, and `(string)` has the highest precedence. In isolation, `(string) $x instanceof C` should therefore be parsed as `((string)$x) instanceof C`, and `! $x instanceof C` as `!($x instanceof C)`. But what is supposed to happen if you stack them in this order? Does `instanceof C` grab the `$x` operand because it has higher precedence than `!`? Or does `(string)` protect its whole operand because it has higher precedence than `instanceof`, giving `((string)!$x) instanceof C`?
---
*Edit:*
- Omission: Unary `&` (for creating references) is not listed at all. The `&` entry in the table (near the middle, left associative) only fits infix `&` (bitwise AND).
- Omission: `->` and `::` are not listed. I assume they should be in the same row as `[`, but who knows.<|eost|><|sor|>Oof.
I wonder if some of these were true in PHP 5 and nobody thought to update for the significant parsing changes in PHP 7.<|eor|><|soopr|>We can check:
- Wrong precedence of `**`: https://3v4l.org/agN3E
Has been there unchanged since 5.6.0 when `**` was introduced.
- Wrong precedence of `clone`: https://3v4l.org/mL7H1
Present since at least 5.4.0. Earlier versions throw a syntax error at `[`.
- Wrong associativity of `instanceof`: https://3v4l.org/kiho6
Has been there unchanged since 5.0.0 when `instanceof` was introduced.
So no changes in PHP 7.
The fun part now is figuring out which part is wrong (and should have bugs filed against it), the implementation or the documentation (or both). I assume there is no specification.<|eoopr|><|eoss|><|endoftext|> | 7 |
lolphp | Takeoded | 69mfd0 | <|sols|><|sot|>be careful where you put implementing classes<|eot|><|sol|>https://3v4l.org/LudAO<|eol|><|eols|><|endoftext|> | 48 |
lolphp | nikic | dh7vnot | <|sols|><|sot|>be careful where you put implementing classes<|eot|><|sol|>https://3v4l.org/LudAO<|eol|><|soopr|>if anyone can explain why this limitation exists for implementing classes and not for other classes, i'm all ears<|eoopr|><|sor|>The tl;dr is that right now class hoisting occurs as a consequence of early binding. Class definitions are only hoisted if they can be early bound. Early binding for classes that implement interfaces is not supported -- and for internal interfaces in particular (as in this example) it cannot be supported, because this is SHM incompatible.
With the AST in PHP 7 we should (in theory) be able to decouple class hoisting from early binding, though PHP's support for conditionally defined classes makes the precise semantics here non-trivial and potentially BC breaking.<|eor|><|eols|><|endoftext|> | 18 |
lolphp | beerdude26 | dh7u6d8 | <|sols|><|sot|>be careful where you put implementing classes<|eot|><|sol|>https://3v4l.org/LudAO<|eol|><|soopr|>if anyone can explain why this limitation exists for implementing classes and not for other classes, i'm all ears<|eoopr|><|sor|>Countable presumably has return types and input types on its methods and class arguments. Without providing a spec for C2, PHP has no way of knowing if C2 follows the spec of Countable. This is put in place to prevent unexpected behavior and confusing runtime errors.<|eor|><|sor|>Surely this could be fixed by parsing in two phases <|eor|><|sor|>Only PHP 7 has a notion of an AST, and thus only PHP 7 would be able to do a staged parsing pass.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | SnowdogU77 | dh7p5ur | <|sols|><|sot|>be careful where you put implementing classes<|eot|><|sol|>https://3v4l.org/LudAO<|eol|><|soopr|>if anyone can explain why this limitation exists for implementing classes and not for other classes, i'm all ears<|eoopr|><|sor|>Countable presumably has return types and input types on its methods and class arguments. Without providing a spec for C2, PHP has no way of knowing if C2 follows the spec of Countable. This is put in place to prevent unexpected behavior and confusing runtime errors.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | Takeoded | dh7oq3o | <|sols|><|sot|>be careful where you put implementing classes<|eot|><|sol|>https://3v4l.org/LudAO<|eol|><|soopr|>if anyone can explain why this limitation exists for implementing classes and not for other classes, i'm all ears<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | squiggleslash | dh817qp | <|sols|><|sot|>be careful where you put implementing classes<|eot|><|sol|>https://3v4l.org/LudAO<|eol|><|sor|>I'm not seeing this, as written, as a LOL. You're using a class before defining it, by rights that should be an error.
It's arguable that the "new C1()" line should *also* fail - having an unknown class default to being an empty one seems pointless, but that's apparently not what's vexing the submitter (or I'm misunderstanding, in which case I apologize.)
If you tried to do something similar in C, say, used a function before defining it, then there's a good chance the compiler would complain too, especially if the function returns something other than int.
Defaults are not bad per-se, especially if they'll never break anything. The behavior "If someone uses a class that's not defined, go along with it unless we later find out the structure of the class actually matters" is, well, fine, it's not going to cause unexpected behavior.
<|eor|><|eols|><|endoftext|> | 8 |
lolphp | senj | dh7r13f | <|sols|><|sot|>be careful where you put implementing classes<|eot|><|sol|>https://3v4l.org/LudAO<|eol|><|soopr|>if anyone can explain why this limitation exists for implementing classes and not for other classes, i'm all ears<|eoopr|><|sor|>Countable presumably has return types and input types on its methods and class arguments. Without providing a spec for C2, PHP has no way of knowing if C2 follows the spec of Countable. This is put in place to prevent unexpected behavior and confusing runtime errors.<|eor|><|sor|>Surely this could be fixed by parsing in two phases <|eor|><|eols|><|endoftext|> | 8 |
lolphp | Sarcastinator | dh8m5p5 | <|sols|><|sot|>be careful where you put implementing classes<|eot|><|sol|>https://3v4l.org/LudAO<|eol|><|sor|>I'm not seeing this, as written, as a LOL. You're using a class before defining it, by rights that should be an error.
It's arguable that the "new C1()" line should *also* fail - having an unknown class default to being an empty one seems pointless, but that's apparently not what's vexing the submitter (or I'm misunderstanding, in which case I apologize.)
If you tried to do something similar in C, say, used a function before defining it, then there's a good chance the compiler would complain too, especially if the function returns something other than int.
Defaults are not bad per-se, especially if they'll never break anything. The behavior "If someone uses a class that's not defined, go along with it unless we later find out the structure of the class actually matters" is, well, fine, it's not going to cause unexpected behavior.
<|eor|><|sor|>The lol is that you can't use types before they are defined except when you can.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | nightofgrim | 5rctij | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|eoss|><|endoftext|> | 49 |
lolphp | yawkat | dd6jwt7 | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|sor|>This isn't a WTF, it's the documented behavior of [in_array](http://php.net/manual/en/function.in-array.php).<|eor|><|sor|>It is wtf, it's just the well-understood wtf of weak typing for comparison. <|eor|><|eoss|><|endoftext|> | 53 |
lolphp | vierkantor | dd6kttn | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|sor|>This isn't a WTF, it's the documented behavior of [in_array](http://php.net/manual/en/function.in-array.php).<|eor|><|sor|>Saying "it's documented" doesn't make it less of a WTF. Just like all the {} + [] WATness in JavaScript, which even has an official spec.<|eor|><|eoss|><|endoftext|> | 36 |
lolphp | squiggleslash | dd6zt3h | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|sor|>This isn't a WTF, it's the documented behavior of [in_array](http://php.net/manual/en/function.in-array.php).<|eor|><|sor|>There needs to be a bot here that reminds people that just because something is documented, doesn't stop it from being a LOLPHP.
In fact, *being documented* strengthens the case for weird behavior being a LOLPHP - it means the behavior is **intentional**, rather than a bug in whatever interpreter is in use.<|eor|><|eoss|><|endoftext|> | 24 |
lolphp | arnoutboks | dd6s9zu | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|sor|>Although this is documented, it is indeed an annoying pitfall that the default behavior is non-strict comparison. At my company we have a set of sniffs for PHP_CodeSniffer in effect for catching bugs like this: https://www.moxio.com/blog/10/detecting-hidden-bugs-in-php-code-using-php-codesniffer<|eor|><|eoss|><|endoftext|> | 17 |
lolphp | garagedragon | dddopwl | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|sor|>This isn't a WTF, it's the documented behavior of [in_array](http://php.net/manual/en/function.in-array.php).<|eor|><|sor|>Saying "it's documented" doesn't make it less of a WTF. Just like all the {} + [] WATness in JavaScript, which even has an official spec.<|eor|><|sor|>FWIW theres nothing wat about `{} + []` in JavaScript except for that it doesnt throw
> ({} + [])
"[object Object]"
> ([] + {})
"[object Object]"
> [].toString()
""
> ({}).toString()
"[object Object]"<|eor|><|sor|>What version of JS are you running?
>[]+{}
"[object Object]"
>{}+[]
0<|eor|><|sor|>Thats a quirk of REPLs you cant run into in actual scripts. (Its why my example uses parentheses.)<|eor|><|sor|>I think that's a WAT moment in itself, then. <|eor|><|eoss|><|endoftext|> | 10 |
lolphp | offroadspike | ddhsxtb | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|sor|>So there are two things here:
1) in_array is using the non-strict comparison.
2) 0 == 'CATS'
It wasn't mentioned yet that I see. I think the second point is more important than the non-strict comparison.
The string to int conversion converts 'CATS' to 0 since there is no number in the string. Thus 0 == 0. This is the more unexpected behavior I think.
$array = ['7 CATS','6 DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
This would correctly fail to print the found zero string, since '7 CATS' to string is 7.
0 == 'CATS' (true)
false == 'CATS' (false)
Fun stuff.<|eor|><|eoss|><|endoftext|> | 9 |
lolphp | bwoebi | dd74a7e | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|sor|>This isn't a WTF, it's the documented behavior of [in_array](http://php.net/manual/en/function.in-array.php).<|eor|><|sor|>The WTF is the default of in_array() <|eor|><|eoss|><|endoftext|> | 9 |
lolphp | TQpl0nk | dd70n71 | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|sor|>This isn't a WTF, it's the documented behavior of [in_array](http://php.net/manual/en/function.in-array.php).<|eor|><|sor|>Still WTF...<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | NXTangl | ddbpquw | <|soss|><|sot|>0 is in array of cats and dogs<|eot|><|sost|>PHP 7.0.1
<?php
$array = ['CATS','DOGS'];
if(in_array(0, $array)===true){
echo 'found zero!';
}
?>
Result: 'found zero!'
Run it yourself: http://sandbox.onlinephpfunctions.com/code/2043564ef944a98b8ecd9c95b6ecf1b1e8941417<|eost|><|sor|>While valid, this is just a symptom of the larger PHP weak-typing stupidity.
Still, it's good to have something about the dangers of weak typing be displayed on the front page every once in a while, since the weak typing thing is probably the most insidious and truly dangerous part of PHP. <|eor|><|eoss|><|endoftext|> | 5 |
lolphp | fdelta1 | 5pk2rl | <|sols|><|sot|>strtotime() accepts "DD Month YYYY" and "Month DD, YYYY" as valid formats, but fails when given "DD Month, YYYY"<|eot|><|sol|>https://en.wiktionary.org/wiki/Wiktionary:Grease_pit#Template:quote-journal<|eol|><|eols|><|endoftext|> | 49 |
lolphp | fdelta1 | dcrxlqv | <|sols|><|sot|>strtotime() accepts "DD Month YYYY" and "Month DD, YYYY" as valid formats, but fails when given "DD Month, YYYY"<|eot|><|sol|>https://en.wiktionary.org/wiki/Wiktionary:Grease_pit#Template:quote-journal<|eol|><|sor|>Say it supported both `DD MM, YYYY` and `MM DD, YYYY`. What date would `01 02, 2016` be? The second of January, or the first of February?
The real lolphp is having PHP automatically try to figure out what date format it's given, instead of making the programmer input the date format (possibly with an option of attempting to auto-detect).<|eor|><|soopr|>Neither apparently, the answer to that question is False.
https://3v4l.org/SmthS<|eoopr|><|eols|><|endoftext|> | 44 |
lolphp | mort96 | dcruggz | <|sols|><|sot|>strtotime() accepts "DD Month YYYY" and "Month DD, YYYY" as valid formats, but fails when given "DD Month, YYYY"<|eot|><|sol|>https://en.wiktionary.org/wiki/Wiktionary:Grease_pit#Template:quote-journal<|eol|><|sor|>Say it supported both `DD MM, YYYY` and `MM DD, YYYY`. What date would `01 02, 2016` be? The second of January, or the first of February?
The real lolphp is having PHP automatically try to figure out what date format it's given, instead of making the programmer input the date format (possibly with an option of attempting to auto-detect).<|eor|><|eols|><|endoftext|> | 38 |
lolphp | n3xg3n | dcsdk8m | <|sols|><|sot|>strtotime() accepts "DD Month YYYY" and "Month DD, YYYY" as valid formats, but fails when given "DD Month, YYYY"<|eot|><|sol|>https://en.wiktionary.org/wiki/Wiktionary:Grease_pit#Template:quote-journal<|eol|><|sor|>Say it supported both `DD MM, YYYY` and `MM DD, YYYY`. What date would `01 02, 2016` be? The second of January, or the first of February?
The real lolphp is having PHP automatically try to figure out what date format it's given, instead of making the programmer input the date format (possibly with an option of attempting to auto-detect).<|eor|><|soopr|>Neither apparently, the answer to that question is False.
https://3v4l.org/SmthS<|eoopr|><|sor|>The real lolphp is always in the comments.<|eor|><|eols|><|endoftext|> | 23 |
lolphp | fdelta1 | dct9m8c | <|sols|><|sot|>strtotime() accepts "DD Month YYYY" and "Month DD, YYYY" as valid formats, but fails when given "DD Month, YYYY"<|eot|><|sol|>https://en.wiktionary.org/wiki/Wiktionary:Grease_pit#Template:quote-journal<|eol|><|sor|>To be fair, nobody writes dates as *23 January, 2016*. The comma does not belong there.<|eor|><|soopr|>True. But you wouldn't expect it to reinterpret it as 23 January CURRENTYEAR.<|eoopr|><|eols|><|endoftext|> | 9 |
lolphp | mort96 | dcsdp87 | <|sols|><|sot|>strtotime() accepts "DD Month YYYY" and "Month DD, YYYY" as valid formats, but fails when given "DD Month, YYYY"<|eot|><|sol|>https://en.wiktionary.org/wiki/Wiktionary:Grease_pit#Template:quote-journal<|eol|><|sor|>Say it supported both `DD MM, YYYY` and `MM DD, YYYY`. What date would `01 02, 2016` be? The second of January, or the first of February?
The real lolphp is having PHP automatically try to figure out what date format it's given, instead of making the programmer input the date format (possibly with an option of attempting to auto-detect).<|eor|><|soopr|>Neither apparently, the answer to that question is False.
https://3v4l.org/SmthS<|eoopr|><|sor|>so PHP doesn't accept `MM DD. YYYY` as a valid format? Why does your title say it does then?
EDIT: oh, `Month` as in the full name of the month, not as in two digits signifying month. I misunderstood, sorry.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | Porges | dcsikrr | <|sols|><|sot|>strtotime() accepts "DD Month YYYY" and "Month DD, YYYY" as valid formats, but fails when given "DD Month, YYYY"<|eot|><|sol|>https://en.wiktionary.org/wiki/Wiktionary:Grease_pit#Template:quote-journal<|eol|><|sor|>Excel has the opposite: it parses `DD Month, YYYY` but not `Month DD, YYYY`.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | ZiggyTheHamster | dct65jr | <|sols|><|sot|>strtotime() accepts "DD Month YYYY" and "Month DD, YYYY" as valid formats, but fails when given "DD Month, YYYY"<|eot|><|sol|>https://en.wiktionary.org/wiki/Wiktionary:Grease_pit#Template:quote-journal<|eol|><|sor|>To be fair, nobody writes dates as *23 January, 2016*. The comma does not belong there.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Yaamboo | dcsdri0 | <|sols|><|sot|>strtotime() accepts "DD Month YYYY" and "Month DD, YYYY" as valid formats, but fails when given "DD Month, YYYY"<|eot|><|sol|>https://en.wiktionary.org/wiki/Wiktionary:Grease_pit#Template:quote-journal<|eol|><|sor|>Say it supported both `DD MM, YYYY` and `MM DD, YYYY`. What date would `01 02, 2016` be? The second of January, or the first of February?
The real lolphp is having PHP automatically try to figure out what date format it's given, instead of making the programmer input the date format (possibly with an option of attempting to auto-detect).<|eor|><|soopr|>Neither apparently, the answer to that question is False.
https://3v4l.org/SmthS<|eoopr|><|sor|>so PHP doesn't accept `MM DD. YYYY` as a valid format? Why does your title say it does then?
EDIT: oh, `Month` as in the full name of the month, not as in two digits signifying month. I misunderstood, sorry.<|eor|><|sor|>Title says month dd, yyyy. So February 01, 2017.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | the_alias_of_andrea | 42u1hp | <|sols|><|sot|>consistency is great<|eot|><|sol|>https://3v4l.org/2qdPp<|eol|><|eols|><|endoftext|> | 48 |
lolphp | the_alias_of_andrea | czd38cv | <|sols|><|sot|>consistency is great<|eot|><|sol|>https://3v4l.org/2qdPp<|eol|><|soopr|>What's going on here? Well, string-to-integer conversion handles overflow differently from float-to-integer conversion. Because PHP.
It might appear things were fixed pre-5.4 and in HHVM, but that's not actually the case, it's just that [floating-point overflow was completely broken on some platforms](https://3v4l.org/42Imk), and it coincidentally produced the same value.<|eoopr|><|eols|><|endoftext|> | 30 |
lolphp | djsumdog | 3v56xi | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|eols|><|endoftext|> | 47 |
lolphp | iheartrms | cxkg9ew | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>Per /u/antpocus over on /r/programming:
> Ooh, only 137 compiler warnings and > 102 failed tests! That's a huge
> improvement from 5.6's 638
> warnings and 114 failed tests!
His post had links to the actual failing tests, not sure how to linkify above. If he posts here I'll delete mine.
<|eor|><|eols|><|endoftext|> | 33 |
lolphp | gearvOsh | cxkqnmq | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>> what's still hopelessly broken?
PHP still not a deprecated language?<|eor|><|sor|>PHP 7 is far far far less shittier than PHP 5.2/3 was.<|eor|><|sor|>How so? Honest question.<|eor|><|sor|>Just a few off the top of my head:
- The interpreter has been rewritten to use an AST/lexer layer, which in turn fixed a large amount of syntax issues. http://php.net/manual/en/migration70.incompatible.php
- Errors are slowly being phased out and replaced with exceptions. This allows fatals and other errors to be caught now.
- All these new features: http://php.net/manual/en/migration70.new-features.php
But yeah, PHP7 is basically a version that is making great strides to fix what was broken with PHP.<|eor|><|eols|><|endoftext|> | 32 |
lolphp | postmodest | cxkm0h0 | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>Per /u/antpocus over on /r/programming:
> Ooh, only 137 compiler warnings and > 102 failed tests! That's a huge
> improvement from 5.6's 638
> warnings and 114 failed tests!
His post had links to the actual failing tests, not sure how to linkify above. If he posts here I'll delete mine.
<|eor|><|sor|>"The tests failed because pear.php.net has been down"
*titter*<|eor|><|eols|><|endoftext|> | 23 |
lolphp | OneWingedShark | cxkgfo1 | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>>So what's fixed and what's still hopelessly broken?
Well, despite how it's obviously needed, the type-annotation system is -- you simply cannot "bolt on" certain things: security, concurrency, and type-systems are three.<|eor|><|eols|><|endoftext|> | 22 |
lolphp | gearvOsh | cxko7wq | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>> what's still hopelessly broken?
PHP still not a deprecated language?<|eor|><|sor|>PHP 7 is far far far less shittier than PHP 5.2/3 was.<|eor|><|eols|><|endoftext|> | 19 |
lolphp | Artemis2 | cxkw0bi | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>Off the top of my head, unicode? Let's just wait until they release PHP 6<|eor|><|eols|><|endoftext|> | 18 |
lolphp | vithos | cxkjler | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>Per /u/antpocus over on /r/programming:
> Ooh, only 137 compiler warnings and > 102 failed tests! That's a huge
> improvement from 5.6's 638
> warnings and 114 failed tests!
His post had links to the actual failing tests, not sure how to linkify above. If he posts here I'll delete mine.
<|eor|><|sor|>> Ooh, only [137 compiler warnings](http://gcov.php.net/viewer.php?version=PHP_7_0&func=compile_results) and [102 failed tests](http://gcov.php.net/viewer.php?version=PHP_7_0&func=tests)! That's a huge improvement from 5.6's [638 warnings](http://gcov.php.net/viewer.php?version=PHP_5_6&func=compile_results) and [114 failed tests](http://gcov.php.net/viewer.php?version=PHP_5_6&func=tests)!
I just clicked "source" under [the comment](https://www.reddit.com/r/programming/comments/3v4l98/php_7_released/cxkazco), might be a RES feature.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | AlGoreBestGore | cxkfk5u | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>Who needs PHP 6 when you can have PHP 7?<|eor|><|eols|><|endoftext|> | 15 |
lolphp | Cuddlefluff_Grim | cxlmssc | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>Who needs PHP 6 when you can have PHP 7?<|eor|><|sor|>[deleted]<|eor|><|sor|>Microsoft didn't cancel Windows 9 because they weren't competent enough to implement some core feature<|eor|><|eols|><|endoftext|> | 12 |
lolphp | McGlockenshire | cxkzdxo | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|>> what's still hopelessly broken?
PHP still not a deprecated language?<|eor|><|sor|>PHP 7 is far far far less shittier than PHP 5.2/3 was.<|eor|><|sor|>How so? Honest question.<|eor|><|sor|>Just a few off the top of my head:
- The interpreter has been rewritten to use an AST/lexer layer, which in turn fixed a large amount of syntax issues. http://php.net/manual/en/migration70.incompatible.php
- Errors are slowly being phased out and replaced with exceptions. This allows fatals and other errors to be caught now.
- All these new features: http://php.net/manual/en/migration70.new-features.php
But yeah, PHP7 is basically a version that is making great strides to fix what was broken with PHP.<|eor|><|sor|>Well, good. There was a time when they wouldn't acknowledge the problems.<|eor|><|sor|>php-internals is still a "toxic kindergarten" but the RFC process has breathed new life into things. No longer can a few select individuals put a stop to progress simply because they don't like a feature.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | Creshal | cxmthua | <|sols|><|sot|>PHP 7 has just been released. So what's fixed and what's still hopelessly broken?<|eot|><|sol|>https://github.com/php/php-src/releases/tag/php-7.0.0<|eol|><|sor|><|eor|><|soopr|>Um...what other languages throw exceptions for that? Java/Scala give you +/- Infinity. If anything, they're now more like other sane languages. Dividing by zero isn't wrong. The result is just "undefined" in Mathematics.<|eoopr|><|sor|>The result is very much defined in maths. IEEE 754 mandates that floating division by zero *can* return infinity, *or* throw a (hardware, no less!) exception.
* C compilers warn on division by zero, and C by default uses FPU exceptions, terminating programs with the specially reserved exit code 136 on encountering one.
* Same in Fortran
* Java, Python and Ruby, similarly, throw a (catchable) software exception
JavaScript is very much not a "sane language". PHP defaulting to the same non-standard, rather useless interpretation of the standard may not be "wrong", but it certainly isn't helpful<|eor|><|eols|><|endoftext|> | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.