subreddit stringclasses 7
values | author stringlengths 3 20 | id stringlengths 5 7 | content stringlengths 67 30.4k | score int64 0 140k |
|---|---|---|---|---|
lolphp | FurriesRuinEverythin | dnk0vzt | <|sols|><|sot|>PHP's DateTime inconsistent behaviour regarding timezones fucked my day and I spent more time than I care to admit testing until I could consistently reproduce its behaviours.<|eot|><|sol|>https://www.dropbox.com/s/2ah1nomu1i3l5ac/how%20not%20to%20get%20bitten%20by%20fucking%20shitty%20php%20dates.pdf?dl=0<|eol|><|soopr|>These are my results from testing over and over again.
It is probably well known, but it is *not* in the documentation and it makes no sense for these inconsistencies. I think, either change the timestamp, or don't change it. Either offset the output from format(), or don't offset it. But don't make the cunting thing do it differently depending on when the timezone is set, and FFS, if you still decide you are going to do this bullshit, then fucking document it. FFS.<|eoopr|><|sor|>then add your work to the documentation
?
I did struggle with it too but you can help others by doing that :o
http://php.net/manual/add-note.php?sect=class.datetime&redirect=http://php.net/manual/en/class.datetime.php<|eor|><|sor|>Right, because the notes added to the PHP docs by random users on the internet are *soooo* reliable.
Hell, the fact that a comment section exists on the official PHP docs is a lolphp in and of itself.<|eor|><|soopr|>Exactly.
Part of what caused me so much grief when debugging this issue was inconsistent/conflicting information and disagreement between people in the php manual's comment section, and on a few stack overflow threads I came across. That, and the fact that I hadn't slept in close to 48 hours, but let's not go there.
In my not so humble opinion, the job of documenting how an API works really falls on the implementer. Because realistically, the only person who 100% knows precisely how it works is the person who implements it. It shouldn't be left up to the end users to figure out how it works by trial and error and then post amendments.<|eoopr|><|eols|><|endoftext|> | 9 |
lolphp | Bl00dsoul | dnewpnw | <|sols|><|sot|>PHP's DateTime inconsistent behaviour regarding timezones fucked my day and I spent more time than I care to admit testing until I could consistently reproduce its behaviours.<|eot|><|sol|>https://www.dropbox.com/s/2ah1nomu1i3l5ac/how%20not%20to%20get%20bitten%20by%20fucking%20shitty%20php%20dates.pdf?dl=0<|eol|><|soopr|>These are my results from testing over and over again.
It is probably well known, but it is *not* in the documentation and it makes no sense for these inconsistencies. I think, either change the timestamp, or don't change it. Either offset the output from format(), or don't offset it. But don't make the cunting thing do it differently depending on when the timezone is set, and FFS, if you still decide you are going to do this bullshit, then fucking document it. FFS.<|eoopr|><|sor|>then add your work to the documentation
?
I did struggle with it too but you can help others by doing that :o
http://php.net/manual/add-note.php?sect=class.datetime&redirect=http://php.net/manual/en/class.datetime.php<|eor|><|sor|>i think a [bugreport](http://bugs.php.net/report.php?bug_type=Documentation+problem&manpage=class.datetime) would be better<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Xymanek | dnflaib | <|sols|><|sot|>PHP's DateTime inconsistent behaviour regarding timezones fucked my day and I spent more time than I care to admit testing until I could consistently reproduce its behaviours.<|eot|><|sol|>https://www.dropbox.com/s/2ah1nomu1i3l5ac/how%20not%20to%20get%20bitten%20by%20fucking%20shitty%20php%20dates.pdf?dl=0<|eol|><|sor|>[deleted]<|eor|><|sor|>If you like Carbon, you should check out Chronos by CakePHP. It's a fork of Carbon with immutable objects (which is really good for value objects I think)<|eor|><|eols|><|endoftext|> | 6 |
lolphp | 6f944ee6 | 6fwu28 | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|eoss|><|endoftext|> | 54 |
lolphp | Schmittfried | dimgrsi | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>1. Write a library that exclusively relies on ::class for storing its string constants. For example: $query = SELECT::class . " * " . FROM::class . " " . MyTable::class;
2. Complain about BC break once this is fixed in PHP.
3. Profit<|eor|><|sor|>I've actually seen people defending this, because checking if the identifier exists would also trigger autoloading and hence harm performance. Until today I wonder why I'd need a name of a class I don't want to load at all. <|eor|><|eoss|><|endoftext|> | 19 |
lolphp | Hauleth | dilme2o | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>Proof https://3v4l.org/sDiK5<|eor|><|eoss|><|endoftext|> | 13 |
lolphp | Holkr | dim8g7f | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>Not really a lol.
Would you really want it to autoload the target class here? Not doing that is a neat performance optimization that allows turning these constants into strings in bytecode.<|eor|><|sor|>Then why even have it in the first place? It doesn't prevent mistyping a class name for example, just silently goes along with it (as is typical with PHP)<|eor|><|eoss|><|endoftext|> | 13 |
lolphp | eMZi0767 | dilorr5 | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>Proof https://3v4l.org/sDiK5<|eor|><|sor|>Should've added `KURWA::class`<|eor|><|eoss|><|endoftext|> | 9 |
lolphp | cosmicsans | dimx4sa | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>Proof https://3v4l.org/sDiK5<|eor|><|sor|>Should've added `KURWA::class`<|eor|><|sor|>`COVFEFE::class`<|eor|><|eoss|><|endoftext|> | 9 |
lolphp | bj_christianson | dimis0x | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>Yeah, but try it combined with "use" and namespaces. :)<|eor|><|sor|>Still works<|eor|><|sor|>[Yep, it does.](https://3v4l.org/FgOhN)<|eor|><|eoss|><|endoftext|> | 9 |
lolphp | the_alias_of_andrea | dimi5es | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>That's intentional behaviour, and it wouldn't be as useful otherwise, because of autoloading.
The point of `::class` isn't to validate that a class exists, it's to statically resolve a namespaced class name.<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | atomheartother | dim8w65 | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>Not really a lol.
Would you really want it to autoload the target class here? Not doing that is a neat performance optimization that allows turning these constants into strings in bytecode.<|eor|><|sor|>Uh, well yes, if I'm accessing a class i sort of expect my code to load the class at run time, not a string.
This looks more like an unfortunate side effect of a performance optimisation than any intended feature.<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | vatzec | dilnj9u | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>Yeah, but try it combined with "use" and namespaces. :)<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | the_alias_of_andrea | dimi8yz | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>Not really a lol.
Would you really want it to autoload the target class here? Not doing that is a neat performance optimization that allows turning these constants into strings in bytecode.<|eor|><|sor|>Then why even have it in the first place? It doesn't prevent mistyping a class name for example, just silently goes along with it (as is typical with PHP)<|eor|><|sor|>It exists so you don't need to type out a fully-qualified class name in full, and to distinguish at the point of use between class names and other strings.
`foobar(Example::class);` vs `foobar('SomeVendor\SomeFramework\Submodule\Submodule\Category\Example')`<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | Schmittfried | diwel9a | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>1. Write a library that exclusively relies on ::class for storing its string constants. For example: $query = SELECT::class . " * " . FROM::class . " " . MyTable::class;
2. Complain about BC break once this is fixed in PHP.
3. Profit<|eor|><|sor|>I've actually seen people defending this, because checking if the identifier exists would also trigger autoloading and hence harm performance. Until today I wonder why I'd need a name of a class I don't want to load at all. <|eor|><|sor|>For optional dependencies: you may check you have this and this class before doing anything.<|eor|><|sor|>How, without loading it?<|eor|><|sor|> if (class_exists(LegacyFoo::class)) {
// do something
elseif (class_exists(NewFoo::class)) {
// do something else
}
if the class doesn't exist then it won't fail so I find it quite useful rather than having to do something like:
if (class_exists('\Long\Namespace\LegacyFoo')) {
// do something
elseif (class_exists('\Long\Namespace\NewFoo')) {
// do something else
}<|eor|><|sor|>Funnily your snippet doesn't do what you say. `class_exists` triggers the autoloader, if you don't suppress it with the second parameter. So if the class is not available, it will fail just as well.
Also, I really struggle with seeing the value of your snippet. It might me useful in some really strange edge-cases, but usually you shouldn't even ask whether a class exists. Either use it (and relying on autoloading; who cares whether `LegacyFoo` is loaded and not used?) or don't. If you don't want to depend on a certain implementation, use proper abstractions. Checking whether classes exist seems kinda like chaining `instanceof` checks. It is a code smell.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | oktupol | dim4q0r | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>Yeah, but try it combined with "use" and namespaces. :)<|eor|><|sor|>Still works<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | tfidry | diw125p | <|soss|><|sot|><CLASSNAME>::class, is valid for any identifier<|eot|><|sost|>A::class // "A"
THIS_DOES_NOT_EXIST::class // "THIS_DOES_NOT_EXIST"<|eost|><|sor|>1. Write a library that exclusively relies on ::class for storing its string constants. For example: $query = SELECT::class . " * " . FROM::class . " " . MyTable::class;
2. Complain about BC break once this is fixed in PHP.
3. Profit<|eor|><|sor|>I've actually seen people defending this, because checking if the identifier exists would also trigger autoloading and hence harm performance. Until today I wonder why I'd need a name of a class I don't want to load at all. <|eor|><|sor|>For optional dependencies: you may check you have this and this class before doing anything.<|eor|><|sor|>How, without loading it?<|eor|><|sor|> if (class_exists(LegacyFoo::class)) {
// do something
elseif (class_exists(NewFoo::class)) {
// do something else
}
if the class doesn't exist then it won't fail so I find it quite useful rather than having to do something like:
if (class_exists('\Long\Namespace\LegacyFoo')) {
// do something
elseif (class_exists('\Long\Namespace\NewFoo')) {
// do something else
}<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | jesseschalken | 5zvkcz | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|eols|><|endoftext|> | 52 |
lolphp | Alexbrainbox | df1q7gm | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
Also [lolpython](https://eval.in/756164), if you so insist.<|eor|><|sor|>The good bit is that it performs completely differently on different variants of PHP. <|eor|><|eols|><|endoftext|> | 26 |
lolphp | nikic | df1ow2s | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
Also [lolpython](https://eval.in/756164), if you so insist.<|eor|><|eols|><|endoftext|> | 25 |
lolphp | nikic | df1t36i | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
Also [lolpython](https://eval.in/756164), if you so insist.<|eor|><|sor|>Is the `$a === $a` resulting in true still IEEE754-compliant? I get the logic of `$a` returning equal to itself, but since it actually has a value of NaN, that should be an exception, shouldnt it?
PHP 5.4.5+ is just looking at the fact that its the same variable and not actually looking at the values.<|eor|><|sor|>No, it's not compliant with IEEE754. Point being that the behavior specified in IEEE754 is not just stupid, but rather actively hostile, and for that reason not strictly followed by a number of programming languages, including PHP, Python, Ruby, C (-ffast-math), etc.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | jesseschalken | df1jv2z | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is just a bug in hhvm, right?<|eor|><|soopr|>No, they should all be `false` since `===` on arrays supposedly recurses through the contents, and `NAN !== NAN`.<|eoopr|><|sor|>You're telling me that this..
$a = [NAN];
var_dump($a === $a);
..is supposed to be `false`? That can't be right?<|eor|><|soopr|>Why not? `NAN` is not equal to itself, and array equality is defined in terms of equality of the elements.<|eoopr|><|eols|><|endoftext|> | 11 |
lolphp | jesseschalken | df1h4y9 | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is just a bug in hhvm, right?<|eor|><|soopr|>No, they should all be `false` since `===` on arrays supposedly recurses through the contents, and `NAN !== NAN`.<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | jesseschalken | df1ko2u | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is just a bug in hhvm, right?<|eor|><|soopr|>No, they should all be `false` since `===` on arrays supposedly recurses through the contents, and `NAN !== NAN`.<|eoopr|><|sor|>You're telling me that this..
$a = [NAN];
var_dump($a === $a);
..is supposed to be `false`? That can't be right?<|eor|><|soopr|>Why not? `NAN` is not equal to itself, and array equality is defined in terms of equality of the elements.<|eoopr|><|sor|>Are you comparing pointers or values with ===?<|eor|><|soopr|>`===` compares pointers for types that are pointers (i.e. objects) and values for types that are values (int, string, float, array...).<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | bj_christianson | df1r2dp | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
Also [lolpython](https://eval.in/756164), if you so insist.<|eor|><|sor|>Is the `$a === $a` resulting in true still IEEE754-compliant? I get the logic of `$a` returning equal to itself, but since it actually has a value of NaN, that should be an exception, shouldnt it?
PHP 5.4.5+ is just looking at the fact that its the same variable and not actually looking at the values.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | jesseschalken | df1wtcd | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
Also [lolpython](https://eval.in/756164), if you so insist.<|eor|><|soopr|>I suppose it is reasonable to lay the blame at IEEE 754 for deciding that `NAN != NAN`. The perf gain of short-circuiting `===` on two references to the same array (that's what it's doing, right?) is probably worth breaking the semantics of this tiny corner case.
I don't know what's going on in HHVM for the third line though...<|eoopr|><|eols|><|endoftext|> | 7 |
lolphp | EmperorArthur | df2jsj0 | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
Also [lolpython](https://eval.in/756164), if you so insist.<|eor|><|sor|>Is it an optimization in python to just return true when comparing an object to itself?
`float('nan') in [float('nan')]` returns False<|eor|><|sor|>That seems to be what PHP and python are doing.
It's probably a spec thing that `NAN != NAN`, but since in every other case `object A === object A` it's pretty reasonable to preform that optimization.
<|eor|><|eols|><|endoftext|> | 7 |
lolphp | prewk | df1jpyq | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is just a bug in hhvm, right?<|eor|><|soopr|>No, they should all be `false` since `===` on arrays supposedly recurses through the contents, and `NAN !== NAN`.<|eoopr|><|sor|>You're telling me that this..
$a = [NAN];
var_dump($a === $a);
..is supposed to be `false`? That can't be right?<|eor|><|eols|><|endoftext|> | 6 |
lolphp | merreborn | df2jtlo | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>If you use legacy array syntax, a lot of the noise goes away, highlighting the deeper issue:
https://3v4l.org/nUUlY<|eor|><|eols|><|endoftext|> | 5 |
lolphp | jesseschalken | df7itmn | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
Also [lolpython](https://eval.in/756164), if you so insist.<|eor|><|sor|>> This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
I disagree. Consider the fact that all comparisons involving NULLs are false in SQL too. Seeing how SQL grows straight from [relational calculus](https://en.wikipedia.org/wiki/Relational_calculus) what do you think is more likely -- that not one but two highly-paid committees inexplicably fucked up the semantics of not-a-value pseudo-values, or that there are valid mathematical reasons for that?
**Edit:** the way to think about it is that the result of NULL = NULL is NULL, just as the result of NULL != NULL, and the same with NaNs. You have a set of numbers (or a particular finite subset), but it turns out that your actual number type is something like `Nullable<actual_double>`, it can be a number or a not-a-number, and not-a-number values infect most operations involving them so that the result is not-a-number as well, regardless. This is because it's useful and still consistent. It's literally a Maybe monad, if that tells you something.
And it's also convenient and somewhat consistent to have joins or `if` operators to automatically deal with `Maybe double` sort of coercing it back to the realm of definite values by treating None as false.
It's all internally consistent, see [Wikipedia on NULL and Three Valued Logic](https://en.wikipedia.org/wiki/Null_\(SQL\)#Comparisons_with_NULL_and_the_three-valued_logic_.283VL.29), and very useful. But yeah, sure, the way it's all automatically propagated or coerced under the hood confuses people that they are working with actual numbers and not with "`Maybe` numbers", so usual rules do not apply when that becomes relevant.<|eor|><|soopr|>If it were a `Maybe` monad, then just like `NULL = NULL` is `NULL` in SQL, _not-a-number_ = _not-a-number_ should be _not-a-bool_, not `false`.
The fact that the result of `==` and `===` is `bool`, not `Maybe bool`, means that the operation isn't being done _in_ the monad, but outside of it, so the `NAN` should compare as equal to itself, just like `Nothing == Nothing` is `True` in Haskell.
[Just 1, Nothing] == [Just 1, Nothing]
True
:: Bool<|eoopr|><|eols|><|endoftext|> | 5 |
lolphp | thewells | df3n5gl | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
Also [lolpython](https://eval.in/756164), if you so insist.<|eor|><|sor|>Is the `$a === $a` resulting in true still IEEE754-compliant? I get the logic of `$a` returning equal to itself, but since it actually has a value of NaN, that should be an exception, shouldnt it?
PHP 5.4.5+ is just looking at the fact that its the same variable and not actually looking at the values.<|eor|><|sor|>No, it's not compliant with IEEE754. Point being that the behavior specified in IEEE754 is not just stupid, but rather actively hostile, and for that reason not strictly followed by a number of programming languages, including PHP, Python, Ruby, C (-ffast-math), etc.<|eor|><|sor|>But it's not stupid, because it's a failure state, to somewhat massively oversimplify, imagine if you had a program the reported the status code of web requests, but could only report there had been an error, if you say all errors are equal, then you get weird behavior.
IEEE754 is like that, because 1/0 isn't a floating point number, and neither is ln(-1), but ln(-1) is a well defined number in the complex numbers while 1/0 still doesn't. NaN is simply a construct made so that way programs that might need to deal with a failure state in floating point arithmetic can do something other than crash because what do you pass back when the arguments don't make sense<|eor|><|eols|><|endoftext|> | 5 |
lolphp | jesseschalken | df1ifqo | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is just a bug in hhvm, right?<|eor|><|soopr|>No, they should all be `false` since `===` on arrays supposedly recurses through the contents, and `NAN !== NAN`.<|eoopr|><|sor|>Ah. In ruby objects are only === if they are the same instance of the object. I never realized just how daft PHP is...<|eor|><|soopr|>That's what PHP does for objects (and in Ruby "everything is an object"). `===` compares for equality for non-objects (ints, floats, arrays...).<|eoopr|><|eols|><|endoftext|> | 5 |
lolphp | ConcernedInScythe | dfcfl5t | <|sols|><|sot|>Does [NAN] === [NAN]? Sometimes, maybe.<|eot|><|sol|>https://3v4l.org/OiYQv<|eol|><|sor|>This is really a lolIEEE754, because NAN comparison semantics are just plain stupid. An irreflexive equality relation is a contradiction in terms.
Also [lolpython](https://eval.in/756164), if you so insist.<|eor|><|sor|>Is the `$a === $a` resulting in true still IEEE754-compliant? I get the logic of `$a` returning equal to itself, but since it actually has a value of NaN, that should be an exception, shouldnt it?
PHP 5.4.5+ is just looking at the fact that its the same variable and not actually looking at the values.<|eor|><|sor|>No, it's not compliant with IEEE754. Point being that the behavior specified in IEEE754 is not just stupid, but rather actively hostile, and for that reason not strictly followed by a number of programming languages, including PHP, Python, Ruby, C (-ffast-math), etc.<|eor|><|sor|>But it's not stupid, because it's a failure state, to somewhat massively oversimplify, imagine if you had a program the reported the status code of web requests, but could only report there had been an error, if you say all errors are equal, then you get weird behavior.
IEEE754 is like that, because 1/0 isn't a floating point number, and neither is ln(-1), but ln(-1) is a well defined number in the complex numbers while 1/0 still doesn't. NaN is simply a construct made so that way programs that might need to deal with a failure state in floating point arithmetic can do something other than crash because what do you pass back when the arguments don't make sense<|eor|><|sor|>> But it's not stupid, because it's a failure state, to somewhat massively oversimplify, imagine if you had a program the reported the status code of web requests, but could only report there had been an error, if you say all errors are equal, then you get weird behavior.
In languages with an option type, `Nothing == Nothing`, and it results in no weird behaviour at all. It's incredibly stupid to represent an error value by *breaking the semantics of the equality operator*.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Takeoded | 5fhmbg | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|eols|><|endoftext|> | 53 |
lolphp | Takeoded | dakao0b | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|soopr|>>socket_create() returns a socket resource on success, or FALSE on error
combined with
> If an invalid domain or type is given, socket_create() defaults to AF_INET and SOCK_STREAM respectively and additionally emits an E_WARNING message.
wtf<|eoopr|><|eols|><|endoftext|> | 42 |
lolphp | Habikki | dakiodw | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|sor|>Well. Obviously you want it to make a connection without telling you what it did.
Truly PHP is ahead of it's time in usability. <|eor|><|eols|><|endoftext|> | 30 |
lolphp | billy_tables | dalmlm6 | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|soopr|>>socket_create() returns a socket resource on success, or FALSE on error
combined with
> If an invalid domain or type is given, socket_create() defaults to AF_INET and SOCK_STREAM respectively and additionally emits an E_WARNING message.
wtf<|eoopr|><|sor|>For some reason, the developers of PHP hate erroring. I have no idea why. Sometimes (actually most times) an error is what I'd want to see rather than some obscure bug-causing functionality that will go unnoticed such as in this fine example.<|eor|><|sor|>Look, mistakes happen. Lets not make a big deal. Lets just plow on relentlessly until the heat death of the universe and hope for the best!<|eor|><|eols|><|endoftext|> | 20 |
lolphp | Takeoded | dakmn94 | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|sor|>I think it's for forward compatibility.<|eor|><|soopr|>a terrible kind. imagine future code running on this engine, and the engine suddenly creates a completely different socket than the 1 you requested
.... iamspeechless<|eoopr|><|eols|><|endoftext|> | 18 |
lolphp | Yamakaky | dakhqvh | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|sor|>I think it's for forward compatibility.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | duskwuff | daldyi2 | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|soopr|>>socket_create() returns a socket resource on success, or FALSE on error
combined with
> If an invalid domain or type is given, socket_create() defaults to AF_INET and SOCK_STREAM respectively and additionally emits an E_WARNING message.
wtf<|eoopr|><|sor|>Possibly for compatibility with stupid old scripts that manage to pass something like `"AF_INET"` (instead of `AF_INET`), or which just blindly pass in an IP address and port? I dunno.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | armornick | dalxfwc | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|sor|>I guess they do some kind of simple parameter validation but instead of exiting the function they use a default? Like:
`int socktype = valid_socket_type(input_socktype) ? input_socktype : default_socktype;`
Still not a very good idea though.<|eor|><|sor|>In fact, that's exactly what they do.
if (arg1 != AF_UNIX
&& arg1 != AF_INET6
&& arg1 != AF_INET) {
php_error_docref(NULL, E_WARNING, "invalid socket domain [" ZEND_LONG_FMT "] specified for argument 1, assuming AF_INET", arg1);
arg1 = AF_INET;
}
<|eor|><|eols|><|endoftext|> | 8 |
lolphp | emilvikstrom | davfv51 | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|soopr|>>socket_create() returns a socket resource on success, or FALSE on error
combined with
> If an invalid domain or type is given, socket_create() defaults to AF_INET and SOCK_STREAM respectively and additionally emits an E_WARNING message.
wtf<|eoopr|><|sor|>For some reason, the developers of PHP hate erroring. I have no idea why. Sometimes (actually most times) an error is what I'd want to see rather than some obscure bug-causing functionality that will go unnoticed such as in this fine example.<|eor|><|sor|>[deleted]<|eor|><|sor|>Then just return false and barge on. Do not do something completely different!
And of course fail fast is better in a dynamically typed system such as PHP. It's very hard to find the real bug when your erronous value was created ten stack frames ago.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | BilgeXA | dalbkvv | <|sols|><|sot|>if an invalid domain or type is given, php does WHAT!!?<|eot|><|sol|>http://php.net/manual/en/function.socket-create.php<|eol|><|sor|>I think it's for forward compatibility.<|eor|><|soopr|>a terrible kind. imagine future code running on this engine, and the engine suddenly creates a completely different socket than the 1 you requested
.... iamspeechless<|eoopr|><|sor|>> the 1
<|eor|><|eols|><|endoftext|> | 5 |
lolphp | prewk | 49ipmx | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|eols|><|endoftext|> | 55 |
lolphp | prewk | d0s1ptz | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|soopr|>Enterprise feature: `// name may vary`<|eoopr|><|eols|><|endoftext|> | 32 |
lolphp | merreborn | d0seeg5 | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|sor|>This is an amusing response (increases semantics!), but I'm not sure if PHP lacking this specific function is really a big problem:
function array_find_callback(array $array, callable $callback) {
foreach ($array as $key => $item) {
if ($callback($item)) {
return $key;
}
}
return null;
}
(I'm deliberately returning the key not the value, because keys can't be `null` so there is no ambiguity between no value found and a found value which is `null`, plus the key provides more information.)<|eor|><|sor|>> (I'm deliberately returning the key not the value, because keys can't be null so there is no ambiguity between no value found and a found value which is null, plus the key provides more information.)
They can be NULL: https://3v4l.org/Pi1qU
<|eor|><|sor|>Not really -- that `null` key gets cast to an empty string: https://3v4l.org/Tnghp<|eor|><|sor|>I'm not sure whether that's better or worse...<|eor|><|sor|>It's not better or worse. *It's PHP*<|eor|><|eols|><|endoftext|> | 21 |
lolphp | the_alias_of_andrea | d0s4944 | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|sor|>This is an amusing response (increases semantics!), but I'm not sure if PHP lacking this specific function is really a big problem:
function array_find_callback(array $array, callable $callback) {
foreach ($array as $key => $item) {
if ($callback($item)) {
return $key;
}
}
return null;
}
(I'm deliberately returning the key not the value, because keys can't be `null` so there is no ambiguity between no value found and a found value which is `null`, plus the key provides more information.)<|eor|><|eols|><|endoftext|> | 16 |
lolphp | Vogtinator | d0sblta | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|sor|>This is an amusing response (increases semantics!), but I'm not sure if PHP lacking this specific function is really a big problem:
function array_find_callback(array $array, callable $callback) {
foreach ($array as $key => $item) {
if ($callback($item)) {
return $key;
}
}
return null;
}
(I'm deliberately returning the key not the value, because keys can't be `null` so there is no ambiguity between no value found and a found value which is `null`, plus the key provides more information.)<|eor|><|sor|>> (I'm deliberately returning the key not the value, because keys can't be null so there is no ambiguity between no value found and a found value which is null, plus the key provides more information.)
They can be NULL: https://3v4l.org/Pi1qU
<|eor|><|sor|>Not really -- that `null` key gets cast to an empty string: https://3v4l.org/Tnghp<|eor|><|sor|>I'm not sure whether that's better or worse...<|eor|><|eols|><|endoftext|> | 15 |
lolphp | the_alias_of_andrea | d0seuez | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|sor|>The really stupid thing in PHP is that you can't use built in functions, for example `isset`, as the callback function for `array_filter`.<|eor|><|sor|>`isset` is not a function, nor could it be one. It doesn't operate on a value, it operates on a variable. Likewise, C's `sizeof` looks like a function but isn't and couldn't be one.
Besides, even if you could use `isset` here, it would be clearer to use `is_null` instead, which you actually can use.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | Mych | d0s6qw8 | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|sor|>This is an amusing response (increases semantics!), but I'm not sure if PHP lacking this specific function is really a big problem:
function array_find_callback(array $array, callable $callback) {
foreach ($array as $key => $item) {
if ($callback($item)) {
return $key;
}
}
return null;
}
(I'm deliberately returning the key not the value, because keys can't be `null` so there is no ambiguity between no value found and a found value which is `null`, plus the key provides more information.)<|eor|><|sor|>> (I'm deliberately returning the key not the value, because keys can't be null so there is no ambiguity between no value found and a found value which is null, plus the key provides more information.)
They can be NULL: https://3v4l.org/Pi1qU
<|eor|><|sor|>Not really -- that `null` key gets cast to an empty string: https://3v4l.org/Tnghp<|eor|><|eols|><|endoftext|> | 14 |
lolphp | AyeGill | d0sm8l9 | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|sor|>This is an amusing response (increases semantics!), but I'm not sure if PHP lacking this specific function is really a big problem:
function array_find_callback(array $array, callable $callback) {
foreach ($array as $key => $item) {
if ($callback($item)) {
return $key;
}
}
return null;
}
(I'm deliberately returning the key not the value, because keys can't be `null` so there is no ambiguity between no value found and a found value which is `null`, plus the key provides more information.)<|eor|><|sor|>> (I'm deliberately returning the key not the value, because keys can't be null so there is no ambiguity between no value found and a found value which is null, plus the key provides more information.)
They can be NULL: https://3v4l.org/Pi1qU
<|eor|><|sor|>Not really -- that `null` key gets cast to an empty string: https://3v4l.org/Tnghp<|eor|><|sor|>>That null key gets cast to an empty string
This shit is why I come to this sub
<|eor|><|eols|><|endoftext|> | 10 |
lolphp | vita10gy | d0sp44o | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|sor|>I don't know what says more about the people involved. The person who basically wrapped a function just because they liked their name better, or the person who pointed out that the trivial bit of code there, that obviously does nothing to alter what happens, doesn't alter anything. <|eor|><|eols|><|endoftext|> | 9 |
lolphp | the_alias_of_andrea | d0saim2 | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|sor|>This is an amusing response (increases semantics!), but I'm not sure if PHP lacking this specific function is really a big problem:
function array_find_callback(array $array, callable $callback) {
foreach ($array as $key => $item) {
if ($callback($item)) {
return $key;
}
}
return null;
}
(I'm deliberately returning the key not the value, because keys can't be `null` so there is no ambiguity between no value found and a found value which is `null`, plus the key provides more information.)<|eor|><|soopr|>Nah, I just miss it from effortlessly working with `Immutable.js` collections in (es6) javascript. So many side-effects, and so much code, in PHP. That accepted SO post is hilarious, though.<|eoopr|><|sor|>I don't think there's a good immutable collections library yet for PHP (there's [a good *mutable* one](https://github.com/morrisonlevi/Ardent), though!). Perhaps someone should make Immutable.php?<|eor|><|eols|><|endoftext|> | 7 |
lolphp | BilgeXA | d0sbrms | <|sols|><|sot|>PHP lacks a proper array_find function.. no worries!<|eot|><|sol|>http://stackoverflow.com/a/14224883/1062912<|eol|><|sor|>61.9k<|eor|><|eols|><|endoftext|> | 6 |
lolphp | _retooth | 305gnj | <|sols|><|sot|>Escaping behavior in strings :/<|eot|><|sol|>http://3v4l.org/iBvY5<|eol|><|eols|><|endoftext|> | 57 |
lolphp | threshar | cppf9u1 | <|sols|><|sot|>Escaping behavior in strings :/<|eot|><|sol|>http://3v4l.org/iBvY5<|eol|><|sor|>I'd just go the nuclear route of "{".$n."}"
<|eor|><|eols|><|endoftext|> | 20 |
lolphp | madsohm | cppbusa | <|sols|><|sot|>Escaping behavior in strings :/<|eot|><|sol|>http://3v4l.org/iBvY5<|eol|><|sor|>Since you're using an interpolated string, I don't really see this as lolbehavior. Character escaping and non-interpolation shouldn't necessarily have the same syntax.
To get what you want, you can use a second set of braces:
echo "{{$n}}";<|eor|><|sor|>But line 7 is just plain wrong then.
How can
print "\{$n}\n" // => \{100}\n
be expected from that? Should it give
\100\n
then?<|eor|><|eols|><|endoftext|> | 13 |
lolphp | fanastril | cppgn4g | <|sols|><|sot|>Escaping behavior in strings :/<|eot|><|sol|>http://3v4l.org/iBvY5<|eol|><|sor|>I tried various iterations of
`print '\{' + "$n" + '\}' + "\n";`
(with and without escaping the curly braces), but apparently the braces don't show up even then? Wat.<|eor|><|sor|>"+" adds integers, string concatenation operator is ".". Avoids some problems of weak type languages.
printf("{%s}\n", $n); //works
echo "{", $n, "}\n"; //works
echo "{" . $n . "}\n"; //works<|eor|><|eols|><|endoftext|> | 13 |
lolphp | thelordofcheese | cppccsb | <|sols|><|sot|>Escaping behavior in strings :/<|eot|><|sol|>http://3v4l.org/iBvY5<|eol|><|sor|>Since you're using an interpolated string, I don't really see this as lolbehavior. Character escaping and non-interpolation shouldn't necessarily have the same syntax.
To get what you want, you can use a second set of braces:
echo "{{$n}}";<|eor|><|sor|>But line 7 is just plain wrong then.
How can
print "\{$n}\n" // => \{100}\n
be expected from that? Should it give
\100\n
then?<|eor|><|sor|>Yeah, while OP's syntax is wrong, the interpreter is wrong as well - at least inconsistent.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | implicit_cast | cppssme | <|sols|><|sot|>Escaping behavior in strings :/<|eot|><|sol|>http://3v4l.org/iBvY5<|eol|><|sor|>Since you're using an interpolated string, I don't really see this as lolbehavior. Character escaping and non-interpolation shouldn't necessarily have the same syntax.
To get what you want, you can use a second set of braces:
echo "{{$n}}";<|eor|><|sor|>The "lol" is that these people cannot even work out a meaning for string literals that can be communicated in any way except "whatever doesn't break the regression test suite."<|eor|><|eols|><|endoftext|> | 10 |
lolphp | poizan42 | cppv1ng | <|sols|><|sot|>Escaping behavior in strings :/<|eot|><|sol|>http://3v4l.org/iBvY5<|eol|><|sor|>Since you're using an interpolated string, I don't really see this as lolbehavior. Character escaping and non-interpolation shouldn't necessarily have the same syntax.
To get what you want, you can use a second set of braces:
echo "{{$n}}";<|eor|><|sor|>The problem isn't what you can or should do, but that this shows that there is something fundamentally wrong in the core of PHP. More specifically, either a character should be escaped or not escaped. if "*c*..." for some character *c* has as special meaning then "\\*c*..." should print out 'c'."...".
But in this case it prints out '\c...'. Somehow the '{' is both escapeable and not escapeable at once. In a well designed parser this simply shouldn't be possible, either a character is in the class of escapeable characters and "\\*c*" is interpreted as a literal '*c*', or the character isn't escapeable and "\\*c*" is interpreted as a literal '\\*c*'.
Of course one could argue that backslashes should simply always make the next character be interpreted literally, though that's a bit late to change now.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | PhantomRacer | cpq93t9 | <|sols|><|sot|>Escaping behavior in strings :/<|eot|><|sol|>http://3v4l.org/iBvY5<|eol|><|sor|>I'd just go the nuclear route of "{".$n."}"
<|eor|><|sor|>Using string literals would be even better.
print '{'.$n.'}';<|eor|><|eols|><|endoftext|> | 6 |
lolphp | allthediamonds | 2gn9tx | <|sols|><|sot|>Strings which contain numbers are treated as numbers on numerical operations, except when they are not.<|eot|><|sol|>https://eval.in/194487<|eol|><|eols|><|endoftext|> | 54 |
lolphp | ajmarks | ckkpxfz | <|sols|><|sot|>Strings which contain numbers are treated as numbers on numerical operations, except when they are not.<|eot|><|sol|>https://eval.in/194487<|eol|><|sor|>Also, octal. PHP's infamous 0d9 "feature" works for hex, decimal, and scientific formatted numeric strings, but not for octal or binary. But that's PHP, they can't even be consistent about their mistakes.<|eor|><|eols|><|endoftext|> | 24 |
lolphp | Various_Pickles | cklbqz7 | <|sols|><|sot|>Strings which contain numbers are treated as numbers on numerical operations, except when they are not.<|eot|><|sol|>https://eval.in/194487<|eol|><|sor|>PHP: Everything is a string, except when its not. Also, sometimes, kinda.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | markrages | ckl9zlg | <|sols|><|sot|>Strings which contain numbers are treated as numbers on numerical operations, except when they are not.<|eot|><|sol|>https://eval.in/194487<|eol|><|sor|>[forgot one](https://eval.in/194807)
<|eor|><|eols|><|endoftext|> | 10 |
lolphp | allthediamonds | ckldbj6 | <|sols|><|sot|>Strings which contain numbers are treated as numbers on numerical operations, except when they are not.<|eot|><|sol|>https://eval.in/194487<|eol|><|sor|>[forgot one](https://eval.in/194807)
<|eor|><|soopr|>Jesus, that's even worse.<|eoopr|><|eols|><|endoftext|> | 10 |
lolphp | Banane9 | ckly30p | <|sols|><|sot|>Strings which contain numbers are treated as numbers on numerical operations, except when they are not.<|eot|><|sol|>https://eval.in/194487<|eol|><|sor|>PHP: Everything is a string, except when its not. Also, sometimes, kinda.<|eor|><|sor|>Make sense? Good.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | thr3ddy | 26wdoi | <|sols|><|sot|>Twitter / TomNomNom: I wrote a book about PHP ...<|eot|><|sol|>https://twitter.com/TomNomNom/status/195304317601849344<|eol|><|eols|><|endoftext|> | 58 |
lolphp | allthediamonds | chvpdmp | <|sols|><|sot|>Twitter / TomNomNom: I wrote a book about PHP ...<|eot|><|sol|>https://twitter.com/TomNomNom/status/195304317601849344<|eol|><|sor|>Oh come on guys. PHP has a lot of faults, but cheap shots like this are disingenuous. It's not like we're talking about brainfuck here - there are plenty of specific things that are irritating about the language, but it also:
1. Is fairly performant for a scripting language
1. Has a shitton of development tools
1. Has a shared-nothing architecture (I know this one's contentious)
1. Has first-class functions and closures
1. Is actively developed, and supported by several fairly stable companies
1. Has an easy array and hash syntax (even if they're the same)
1. Supports tuple unpacking
1. Allows breaking out multiple levels of loops without using goto or exceptions
1. Provides a wide variety of array manipulation functions out-of-the-box
1. Has a package manager that seems to work relatively well
1. Has namespaces
1. Has objects (have you ever used Perl 5's "classes"? For that matter...)
1. Has actual function arguments
PHP has many faults, but those who best understand them are those of us who use it every day. Do we like it? Hell no! But it is still a *good enough* tool that we can get things done, and personally I'd rather be using PHP than Perl or Java.<|eor|><|sor|>> Is fairly performant for a scripting language
It could be if its execution model were not completely bonkers. It's still consistently slower than Ruby or Python the moment you do anything complex, because everything with it requires a bajillion syscalls.
> Has a shitton of development tools
Has a ton of shit development tools indeed. The only one I can think of that could actually be considered "good" objectively is PHPStorm. Maybe Codebug, too. In any case, Xdebug's mere existence offsets the good parts of the aforementioned tools by miles.
> Has a shared-nothing architecture (I know this one's contentious)
If it were actually consistent on this... there are lots of ways to modify the state of the global PHP interpreter.
And, in the real world, as you said, this is hardly a good thing. There are things that an application can share, and it makes little to no sense to rebuild them from scratch on each call.
> Has first-class functions and closures
Too bad the standard library barely uses them and making use of them requires call_user_func_uglyness_god_kill_me_now().
> Is actively developed
... mostly by completely incompetent morons which bikeshed to death every change that could possibly improve PHP in the slightest.
> and supported by several fairly stable companies
... which are too invested into this shitty tool to go back. Some of those fairly stable companies have needed to build, I don't know, *entire virtual machines* so that their PHP applications don't crumble under the incompetence of the language underneath.
> Has an easy array and hash syntax (even if they're the same)
So do lots of other languages. Furthermore, they did so ten to fifteen years before PHP did. And you can't just scrub "they're the same" as if it weren't a huge source of issues.
> Supports tuple unpacking
As of PHP 5.5, yes. Is that really a major feature on a language? "Supports tuple unpacking"? I'm a Pythonista and I don't think I use it that much.
> Allows breaking out multiple levels of loops without using goto or exceptions
Needing this usually means you're doing something very, very wrong.
> Provides a wide variety of array manipulation functions out-of-the-box
What? Have you actually looked at, you know, any other programming language in the past fifteen years? PHP ought to have more functions, because its array is not an array at all, but a mix-and-match of several misunderstood interpretations of what a data structure is, and therefore has to support being a list, a set, a queue and a dictionary at the same time.
Python, Ruby or Clojure are examples of languages with a vastly superior standard library of data structures and data structure operations. I always find myself re-inventing the wheel on PHP.
> Has a package manager that seems to work relatively well
Worst package manager ever. Except for PEAR, PHP's *other* package manager. It's local-by-default, which is good. That's basically where 'good' ends with Composer. Its lock files are an unreadable mess, and the way it solves dependencies means that it takes a whole minute to solve dependencies on a simple Symfony application. Pip, Bundler or NPM could kick its ass any day of the week.
> Has namespaces
At fucking last. If only they weren't \So\Goddamn\Ugly...
> Has objects
wow
such objects
amaze
If you want to compare PHP's objects to the ones on Perl 5, you might as well compare the ones on PHP 4, which actually was around by the time Perl 5 was launched.
> Has actual function arguments
Allow me to remind you that you're talking about the language that refers to functions in the global namespace by SENDING A FREAKING STRING WITH THEIR FREAKING NAME ON IT.
> PHP has many faults, but those who best understand them are those of us who use it every day.
I've used PHP every day for the past six months. I solemnly swear I will never take a PHP job again in my entire life. So much crazy.
> Do we like it? Hell no!
Hey, I agree on that!
> But it is still a good enough tool that we can get things done
Of course you can 'get things done'. You can get things done in `bash` as well. You can forgo websites altogether and get things done with rocks. The reason we don't use rocks, `bash` or PHP for web development is that we're not freaking savages anymore.
Since you mentioned Brainfuck, allow me to note that it has a vastly better design than PHP. It has eight commands which do one thing each and do it well. None of them accept a third, optional parameter to enable strict comparison, none of them accept their arguments in any order and, unlike PHP, Brainfuck accomplishes its intended goal very well.<|eor|><|eols|><|endoftext|> | 23 |
lolphp | VeXCe | chv3z1x | <|sols|><|sot|>Twitter / TomNomNom: I wrote a book about PHP ...<|eot|><|sol|>https://twitter.com/TomNomNom/status/195304317601849344<|eol|><|sor|>I worked with classic asp, on an intranet CMS that was full of stuff ripe for the Daily WTF. Php is a *lot* better than that.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | Banane9 | chw2nar | <|sols|><|sot|>Twitter / TomNomNom: I wrote a book about PHP ...<|eot|><|sol|>https://twitter.com/TomNomNom/status/195304317601849344<|eol|><|sor|>Oh come on guys. PHP has a lot of faults, but cheap shots like this are disingenuous. It's not like we're talking about brainfuck here - there are plenty of specific things that are irritating about the language, but it also:
1. Is fairly performant for a scripting language
1. Has a shitton of development tools
1. Has a shared-nothing architecture (I know this one's contentious)
1. Has first-class functions and closures
1. Is actively developed, and supported by several fairly stable companies
1. Has an easy array and hash syntax (even if they're the same)
1. Supports tuple unpacking
1. Allows breaking out multiple levels of loops without using goto or exceptions
1. Provides a wide variety of array manipulation functions out-of-the-box
1. Has a package manager that seems to work relatively well
1. Has namespaces
1. Has objects (have you ever used Perl 5's "classes"? For that matter...)
1. Has actual function arguments
PHP has many faults, but those who best understand them are those of us who use it every day. Do we like it? Hell no! But it is still a *good enough* tool that we can get things done, and personally I'd rather be using PHP than Perl or Java.<|eor|><|sor|>Stockholm Syndrome?<|eor|><|eols|><|endoftext|> | 7 |
lolphp | phoshi | chvp9uh | <|sols|><|sot|>Twitter / TomNomNom: I wrote a book about PHP ...<|eot|><|sol|>https://twitter.com/TomNomNom/status/195304317601849344<|eol|><|sor|>Oh come on guys. PHP has a lot of faults, but cheap shots like this are disingenuous. It's not like we're talking about brainfuck here - there are plenty of specific things that are irritating about the language, but it also:
1. Is fairly performant for a scripting language
1. Has a shitton of development tools
1. Has a shared-nothing architecture (I know this one's contentious)
1. Has first-class functions and closures
1. Is actively developed, and supported by several fairly stable companies
1. Has an easy array and hash syntax (even if they're the same)
1. Supports tuple unpacking
1. Allows breaking out multiple levels of loops without using goto or exceptions
1. Provides a wide variety of array manipulation functions out-of-the-box
1. Has a package manager that seems to work relatively well
1. Has namespaces
1. Has objects (have you ever used Perl 5's "classes"? For that matter...)
1. Has actual function arguments
PHP has many faults, but those who best understand them are those of us who use it every day. Do we like it? Hell no! But it is still a *good enough* tool that we can get things done, and personally I'd rather be using PHP than Perl or Java.<|eor|><|sor|>1. Kinda true, but it occupies a space where millisecond counting is rarely useful. The small sites would be fine with almost anything, the large sites need faster than PHP anyway.
2. So do many other languages, and they're usually just as good!
3. I'm confused by this point. That's an attribute of software, not language, and given the common structure of webserver/database server I don't think you can even say the culture promotes it.
4. Bad ones, yes, and so does every other language in PHP's niche.
5. As are the competitors.
6. As do the competitors.
7. This is an interesting thing to put as a major advantage to a language, but; As to the competitors;
8. As do-
9. As-
10. As
11. As
12. As
13. As
We make fun of PHP not because it's literally the worst thing in the world, but because it's just good enough to be usable while still being significantly worse than every single competitor.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | nahguri | chvll6w | <|sols|><|sot|>Twitter / TomNomNom: I wrote a book about PHP ...<|eot|><|sol|>https://twitter.com/TomNomNom/status/195304317601849344<|eol|><|sor|>I would like to cite this publication. <|eor|><|eols|><|endoftext|> | 5 |
lolphp | Takeoded | g2exf2 | <|sols|><|sot|>keys can't be float, so lets just silently truncate the key to fit, what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/319M1<|eol|><|eols|><|endoftext|> | 54 |
lolphp | fell_ratio | fnlgs32 | <|sols|><|sot|>keys can't be float, so lets just silently truncate the key to fit, what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/319M1<|eol|><|sor|>This is documented behavior though:
----
The key can either be an integer or a string. The value can be of any type.
Additionally the following key casts will occur:
- Strings containing valid decimal integers, unless the number is preceded by a + sign, will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
- Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.
- Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0.
- Null will be cast to the empty string, i.e. the key null will actually be stored under "".
- Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.<|eor|><|sor|>It can be documented and still be a lol, though.<|eor|><|eols|><|endoftext|> | 37 |
lolphp | AyrA_ch | fnl75yp | <|sols|><|sot|>keys can't be float, so lets just silently truncate the key to fit, what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/319M1<|eol|><|sor|>This is documented behavior though:
----
The key can either be an integer or a string. The value can be of any type.
Additionally the following key casts will occur:
- Strings containing valid decimal integers, unless the number is preceded by a + sign, will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
- Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.
- Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0.
- Null will be cast to the empty string, i.e. the key null will actually be stored under "".
- Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.<|eor|><|eols|><|endoftext|> | 19 |
lolphp | Takeoded | fnl8l0z | <|sols|><|sot|>keys can't be float, so lets just silently truncate the key to fit, what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/319M1<|eol|><|sor|>This is documented behavior though:
----
The key can either be an integer or a string. The value can be of any type.
Additionally the following key casts will occur:
- Strings containing valid decimal integers, unless the number is preceded by a + sign, will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
- Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.
- Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0.
- Null will be cast to the empty string, i.e. the key null will actually be stored under "".
- Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.<|eor|><|soopr|>`Warning: Illegal offset type` should have been thrown for 4/5 of the above.<|eoopr|><|eols|><|endoftext|> | 19 |
lolphp | postmodest | fnlibuf | <|sols|><|sot|>keys can't be float, so lets just silently truncate the key to fit, what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/319M1<|eol|><|sor|>This is documented behavior though:
----
The key can either be an integer or a string. The value can be of any type.
Additionally the following key casts will occur:
- Strings containing valid decimal integers, unless the number is preceded by a + sign, will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
- Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.
- Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0.
- Null will be cast to the empty string, i.e. the key null will actually be stored under "".
- Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.<|eor|><|sor|>It can be documented and still be a lol, though.<|eor|><|sor|>The greater lol is that PHP doesnt differentiate between a list and a dictionary. And theres no native object syntax except new stdclass()<|eor|><|eols|><|endoftext|> | 19 |
lolphp | postmodest | fnlr7lb | <|sols|><|sot|>keys can't be float, so lets just silently truncate the key to fit, what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/319M1<|eol|><|sor|>This is documented behavior though:
----
The key can either be an integer or a string. The value can be of any type.
Additionally the following key casts will occur:
- Strings containing valid decimal integers, unless the number is preceded by a + sign, will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
- Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.
- Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0.
- Null will be cast to the empty string, i.e. the key null will actually be stored under "".
- Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.<|eor|><|sor|>It can be documented and still be a lol, though.<|eor|><|sor|>The greater lol is that PHP doesnt differentiate between a list and a dictionary. And theres no native object syntax except new stdclass()<|eor|><|sor|>If that's the greater lol, what is the greatest lol?<|eor|><|sor|>Basically how a crappy half-assed rip-off of Perl came to be one of the biggest languages Jon the Internet.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | D1551D3N7 | a8q5q9 | <|sols|><|sot|>Reminder that PHP still doesn't correctly parse PUT requests 7 years after this bug report<|eot|><|sol|>https://bugs.php.net/bug.php?id=55815<|eol|><|eols|><|endoftext|> | 52 |
lolphp | SirClueless | ecdak2o | <|sols|><|sot|>Reminder that PHP still doesn't correctly parse PUT requests 7 years after this bug report<|eot|><|sol|>https://bugs.php.net/bug.php?id=55815<|eol|><|sor|>[This](https://www.reddit.com/r/PHP/comments/11uczq/year_old_bug_request_for_put_interested_in_rphps/c6pu9uf/) is the best comment on this situation that I've seen.
Note that this is a common way to handle things in other web frameworks (e.g. [Django](https://groups.google.com/forum/#!msg/django-developers/dxI4qVzrBY4/m_9IiNk_p7UJ)) as well: GET and POST have special treatment to handle the common case of an HTML form encoded in a HTTP request. Other use cases, such as RESTful API interfaces, should be parsing request bodies according to the content-type of the request.<|eor|><|eols|><|endoftext|> | 25 |
lolphp | alercah | ecd4klz | <|sols|><|sot|>Reminder that PHP still doesn't correctly parse PUT requests 7 years after this bug report<|eot|><|sol|>https://bugs.php.net/bug.php?id=55815<|eol|><|soopr|>I was trying to have support for uploading files using curl -T but as it turns out it's not possible for PHP to read the filename from the PUT request.
More lulz /r/PHP discussion: https://www.reddit.com/r/PHP/comments/11uczq/year_old_bug_request_for_put_interested_in_rphps/
Stackoverflow answer incorrectly saying the the filename is not included with the PUT request: https://stackoverflow.com/questions/14479386/how-to-get-filename-in-php-in-put-request<|eoopr|><|sor|>The filename in a PUT request should be the target of the request (that is, the resource identified by the URL), not by the contents of the body. You're looking in the wrong place.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | sproingie | ecdv6qd | <|sols|><|sot|>Reminder that PHP still doesn't correctly parse PUT requests 7 years after this bug report<|eot|><|sol|>https://bugs.php.net/bug.php?id=55815<|eol|><|sor|>[This](https://www.reddit.com/r/PHP/comments/11uczq/year_old_bug_request_for_put_interested_in_rphps/c6pu9uf/) is the best comment on this situation that I've seen.
Note that this is a common way to handle things in other web frameworks (e.g. [Django](https://groups.google.com/forum/#!msg/django-developers/dxI4qVzrBY4/m_9IiNk_p7UJ)) as well: GET and POST have special treatment to handle the common case of an HTML form encoded in a HTTP request. Other use cases, such as RESTful API interfaces, should be parsing request bodies according to the content-type of the request.<|eor|><|sor|>Said comment, and not surprisingly, other comments from PHP devs themselves comes from the assumption that the only thing in a POST can be form data, when it in fact can also be anything. Hell, PHP has to parse two different types of post data, so they should have known better. All PHP has to do is sniff the mime type and parse the entity, the *same as it does for POST*. It fails to surprise me though that PHP falls down at what is essentially its main job due to a basic misunderstanding of it by the core devs.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | alercah | ecd3ewl | <|sols|><|sot|>Reminder that PHP still doesn't correctly parse PUT requests 7 years after this bug report<|eot|><|sol|>https://bugs.php.net/bug.php?id=55815<|eol|><|soopr|>I was trying to have support for uploading files using curl -T but as it turns out it's not possible for PHP to read the filename from the PUT request.
More lulz /r/PHP discussion: https://www.reddit.com/r/PHP/comments/11uczq/year_old_bug_request_for_put_interested_in_rphps/
Stackoverflow answer incorrectly saying the the filename is not included with the PUT request: https://stackoverflow.com/questions/14479386/how-to-get-filename-in-php-in-put-request<|eoopr|><|sor|>I know it should support PUT, but from a protocol standpoint, the request is identical for PUT and POST. Why not just use POST? Since PUT is used to create and POST to create or update, PUT is not necessary for a fully working API<|eor|><|sor|>They are not the same from a protocol standpoint. For instance, proxy can retry a PUT that it isn't sure went through (due to a dropped connection, say), while it can't with a POST.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | alercah | ecd4ne3 | <|sols|><|sot|>Reminder that PHP still doesn't correctly parse PUT requests 7 years after this bug report<|eot|><|sol|>https://bugs.php.net/bug.php?id=55815<|eol|><|soopr|>I was trying to have support for uploading files using curl -T but as it turns out it's not possible for PHP to read the filename from the PUT request.
More lulz /r/PHP discussion: https://www.reddit.com/r/PHP/comments/11uczq/year_old_bug_request_for_put_interested_in_rphps/
Stackoverflow answer incorrectly saying the the filename is not included with the PUT request: https://stackoverflow.com/questions/14479386/how-to-get-filename-in-php-in-put-request<|eoopr|><|sor|>I know it should support PUT, but from a protocol standpoint, the request is identical for PUT and POST. Why not just use POST? Since PUT is used to create and POST to create or update, PUT is not necessary for a fully working API<|eor|><|sor|>They are not the same from a protocol standpoint. For instance, proxy can retry a PUT that it isn't sure went through (due to a dropped connection, say), while it can't with a POST.<|eor|><|sor|>Why not? Using the exact same POST should yield the exact same result.<|eor|><|sor|>No. POST is, in general, not idempotent. For instance, it's quite common that "create a new foo" multiple times results in multiple foos.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | SirClueless | eceggm1 | <|sols|><|sot|>Reminder that PHP still doesn't correctly parse PUT requests 7 years after this bug report<|eot|><|sol|>https://bugs.php.net/bug.php?id=55815<|eol|><|sor|>[This](https://www.reddit.com/r/PHP/comments/11uczq/year_old_bug_request_for_put_interested_in_rphps/c6pu9uf/) is the best comment on this situation that I've seen.
Note that this is a common way to handle things in other web frameworks (e.g. [Django](https://groups.google.com/forum/#!msg/django-developers/dxI4qVzrBY4/m_9IiNk_p7UJ)) as well: GET and POST have special treatment to handle the common case of an HTML form encoded in a HTTP request. Other use cases, such as RESTful API interfaces, should be parsing request bodies according to the content-type of the request.<|eor|><|sor|>Said comment, and not surprisingly, other comments from PHP devs themselves comes from the assumption that the only thing in a POST can be form data, when it in fact can also be anything. Hell, PHP has to parse two different types of post data, so they should have known better. All PHP has to do is sniff the mime type and parse the entity, the *same as it does for POST*. It fails to surprise me though that PHP falls down at what is essentially its main job due to a basic misunderstanding of it by the core devs.<|eor|><|sor|>It can be anything, including things that make no sense to be automatically decoded into a superglobal dictionary of params.
The HTML spec allows for three encodings of forms, and two HTTP methods. So those are the kinds that are treated specially. There are really only two sane things to do here. One is to treat all requests with bodies like they might contain form-data and parse them all into a params dictionary (this is the approach taken by, e.g. [Ruby on Rails](https://api.rubyonrails.org/v5.1.6.1/classes/ActionDispatch/Request.html#method-i-request_parameters) and [Flask](http://flask.pocoo.org/docs/1.0/api/#flask.Request.form)). The other is to special case GET and POST as these are the only request types that can actually contain HTML form values from a browser. This is the approach taken by [Django](https://docs.djangoproject.com/en/2.1/ref/request-response/#django.http.HttpRequest.POST) and [PHP](http://php.net/manual/en/reserved.variables.post.php), and it works fine for creating web servers even if it doesn't help much when building REST APIs. Going down the route of adding superglobals for a bunch of underused HTTP methods (especially when superglobals already aren't sufficient for anything except form data) would lead to insanity.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | sproingie | ecgfor3 | <|sols|><|sot|>Reminder that PHP still doesn't correctly parse PUT requests 7 years after this bug report<|eot|><|sol|>https://bugs.php.net/bug.php?id=55815<|eol|><|sor|>[This](https://www.reddit.com/r/PHP/comments/11uczq/year_old_bug_request_for_put_interested_in_rphps/c6pu9uf/) is the best comment on this situation that I've seen.
Note that this is a common way to handle things in other web frameworks (e.g. [Django](https://groups.google.com/forum/#!msg/django-developers/dxI4qVzrBY4/m_9IiNk_p7UJ)) as well: GET and POST have special treatment to handle the common case of an HTML form encoded in a HTTP request. Other use cases, such as RESTful API interfaces, should be parsing request bodies according to the content-type of the request.<|eor|><|sor|>Said comment, and not surprisingly, other comments from PHP devs themselves comes from the assumption that the only thing in a POST can be form data, when it in fact can also be anything. Hell, PHP has to parse two different types of post data, so they should have known better. All PHP has to do is sniff the mime type and parse the entity, the *same as it does for POST*. It fails to surprise me though that PHP falls down at what is essentially its main job due to a basic misunderstanding of it by the core devs.<|eor|><|sor|>It can be anything, including things that make no sense to be automatically decoded into a superglobal dictionary of params.
The HTML spec allows for three encodings of forms, and two HTTP methods. So those are the kinds that are treated specially. There are really only two sane things to do here. One is to treat all requests with bodies like they might contain form-data and parse them all into a params dictionary (this is the approach taken by, e.g. [Ruby on Rails](https://api.rubyonrails.org/v5.1.6.1/classes/ActionDispatch/Request.html#method-i-request_parameters) and [Flask](http://flask.pocoo.org/docs/1.0/api/#flask.Request.form)). The other is to special case GET and POST as these are the only request types that can actually contain HTML form values from a browser. This is the approach taken by [Django](https://docs.djangoproject.com/en/2.1/ref/request-response/#django.http.HttpRequest.POST) and [PHP](http://php.net/manual/en/reserved.variables.post.php), and it works fine for creating web servers even if it doesn't help much when building REST APIs. Going down the route of adding superglobals for a bunch of underused HTTP methods (especially when superglobals already aren't sufficient for anything except form data) would lead to insanity.<|eor|><|sor|>After thinking on it some more (and deleting a previous reply), your argument convinced me. The superglobals are only about form data, and since any attempt to stick form data into a PUT is going to be a "manual" process anyway (curl notwithstanding, it can just switch the verb) extracting it might as well involve explicitly decoding the form. Most APIs are going to be speaking JSON anyway (or at least something better than form-data), so as a practical matter, adding `$_PUT` superglobals would just increase PHP's already wide attack surface for no real benefit.
It still offends my sense of elegance, but looking for elegance in PHP...<|eor|><|eols|><|endoftext|> | 5 |
lolphp | alercah | ecg317z | <|sols|><|sot|>Reminder that PHP still doesn't correctly parse PUT requests 7 years after this bug report<|eot|><|sol|>https://bugs.php.net/bug.php?id=55815<|eol|><|soopr|>I was trying to have support for uploading files using curl -T but as it turns out it's not possible for PHP to read the filename from the PUT request.
More lulz /r/PHP discussion: https://www.reddit.com/r/PHP/comments/11uczq/year_old_bug_request_for_put_interested_in_rphps/
Stackoverflow answer incorrectly saying the the filename is not included with the PUT request: https://stackoverflow.com/questions/14479386/how-to-get-filename-in-php-in-put-request<|eoopr|><|sor|>I know it should support PUT, but from a protocol standpoint, the request is identical for PUT and POST. Why not just use POST? Since PUT is used to create and POST to create or update, PUT is not necessary for a fully working API<|eor|><|sor|>They are not the same from a protocol standpoint. For instance, proxy can retry a PUT that it isn't sure went through (due to a dropped connection, say), while it can't with a POST.<|eor|><|sor|>Why not? Using the exact same POST should yield the exact same result.<|eor|><|sor|>Proxies don't know if you're using REST or not. Any proxy that retries a POST risks, for example, letting an ecommerce website double charge a customer. Definitely not something you want a proxy to do.
<|eor|><|sor|>A proxy should never retry a request unless the client explicitly instructs it to do so<|eor|><|sor|>[RFC 7230](https://tools.ietf.org/html/rfc7230#section-6.3.1) explicitly permits proxies to retry idempotent requests: GET, HEAD, OPTIONS, TRACE, PUT, and DELETE.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | lord_braleigh | 9hrvke | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|eols|><|endoftext|> | 55 |
lolphp | Joniator | e6e53ma | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>[TIL you can use "" in a php classname](https://3v4l.org/mi3Gh)
Apparently you can even use <DELETE> (Ascii 177/oct, U+007f) in your classname. At least according to their "sanity check"<|eor|><|eols|><|endoftext|> | 31 |
lolphp | z500 | e6eb744 | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>[TIL you can use "" in a php classname](https://3v4l.org/mi3Gh)
Apparently you can even use <DELETE> (Ascii 177/oct, U+007f) in your classname. At least according to their "sanity check"<|eor|><|sor|>I feel like [this](https://www.reddit.com/r/rust/comments/5penft/parallelizing_enjarify_in_go_and_rust/dcsgk7n/) is relevant yet again<|eor|><|eols|><|endoftext|> | 28 |
lolphp | AllezAllezAllezAllez | e6e6xxi | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>[TIL you can use "" in a php classname](https://3v4l.org/mi3Gh)
Apparently you can even use <DELETE> (Ascii 177/oct, U+007f) in your classname. At least according to their "sanity check"<|eor|><|sor|>Just as I expected, the developers of PHP subscribe to different standards of sanity than I do ;)<|eor|><|eols|><|endoftext|> | 26 |
lolphp | PGLubricants | e6el93j | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>If I tried to push this code as a pull request in a non production, pre alpha, POC unit test-data class, as a comment, on my own branch, it would *still* get rejected. <|eor|><|eols|><|endoftext|> | 18 |
lolphp | nexxai | e6etsy4 | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>[TIL you can use "" in a php classname](https://3v4l.org/mi3Gh)
Apparently you can even use <DELETE> (Ascii 177/oct, U+007f) in your classname. At least according to their "sanity check"<|eor|><|sor|>I feel like [this](https://www.reddit.com/r/rust/comments/5penft/parallelizing_enjarify_in_go_and_rust/dcsgk7n/) is relevant yet again<|eor|><|sor|>what the fuck<|eor|><|eols|><|endoftext|> | 12 |
lolphp | TorbenKoehn | e6g2fvn | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>[TIL you can use "" in a php classname](https://3v4l.org/mi3Gh)
Apparently you can even use <DELETE> (Ascii 177/oct, U+007f) in your classname. At least according to their "sanity check"<|eor|><|sor|>[Uhm....](https://3v4l.org/EuKDq)<|eor|><|eols|><|endoftext|> | 11 |
lolphp | Joniator | e6ebfp6 | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>[TIL you can use "" in a php classname](https://3v4l.org/mi3Gh)
Apparently you can even use <DELETE> (Ascii 177/oct, U+007f) in your classname. At least according to their "sanity check"<|eor|><|sor|>I feel like [this](https://www.reddit.com/r/rust/comments/5penft/parallelizing_enjarify_in_go_and_rust/dcsgk7n/) is relevant yet again<|eor|><|sor|>Oh my god
<|eor|><|eols|><|endoftext|> | 11 |
lolphp | F-J-W | e6e08pk | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>The fuck?<|eor|><|eols|><|endoftext|> | 9 |
lolphp | SaraMG | e73hgdy | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>PHP predates unicode being a dominant standard. In PHP's early days, anything outside of ASCII could (probably) be assumed to be a locale specific character in its own right. Maybe word class, maybe not.
Rather than try to solve the problem of all the world's languages and encodings, PHP just said, "We're ASCII first, and anything else is your responsibility as a programmer to figure out". That turns out to have been a GOOD decision, as now that (mostly) everyone has standardized on UTF-8, that ascii-transparent encoding *just works*.
You're still responsible for not being a dumbass by using in your class name, but if you decide to do that after all, where does the lol belong? It belongs on you; Dumbass.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | nikic | e6q2lv9 | <|sols|><|sot|>Valid characters in a class name<|eot|><|sol|>https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_execute_API.c#L960<|eol|><|sor|>[TIL you can use "" in a php classname](https://3v4l.org/mi3Gh)
Apparently you can even use <DELETE> (Ascii 177/oct, U+007f) in your classname. At least according to their "sanity check"<|eor|><|sor|>DEL is no longer a valid label character nowadays (the link is PHP 5.6). It was probably allowed due to an off-by-one error at some point and carried over everywhere, until it was dropped in PHP 7.1 (iirc).<|eor|><|eols|><|endoftext|> | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.