subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
CaptainsLincolnLog
cpxraj8
<|sols|><|sot|>Why would someone who knows how to use closures, generators, etc. bother with PHP?<|eot|><|sol|>http://www.ibm.com/developerworks/opensource/library/wa-php-renewed_1/index.html?ca=drs-<|eol|><|sor|>Look, I don't like PHP. If it was a choice between getting fired and doing full-time PHP development, I'd polish my rsum. But isn't this a good thing for the people who are stuck writing PHP and can't avoid it? It's like the more recent improvements to Javascript; ES3 is landmine city, but ES5 is pretty okay and ES6 is gettin' to be an alright thing to use. So sure, the likes of C#, Haskell, or Lisp are better languages, but if you can't *not* write Javascript, it's at least not a bad experience now. Yes, Javascript's not as bad as PHP, but shouldn't we be happy that those of us who have to endure PHP have *some* niceties?<|eor|><|sor|>JavaScript isn't as bad as PHP because it doesn't try to make kitchen sink soup and isn't engineered by too many cooks.<|eor|><|sor|>This is important. While JavaScript's design is quite terrible, it is, at least, an unified design. Contrast this with PHP, where each function has its own terrible design decisions bundled with it. Sure, I'd rather use anything else, but if PHP and JavaScript were the only choices, JavaScript is clearly the winner.<|eor|><|sor|>It's actually not that terrible. The syntax is rather simple, and the behavior is consistent. You can look at some random code and have a good idea of what it does, unlike PHP or Perl. Most of the yuck factor comes from old browser-based code. If you look at upcoming evolutions of the language, ES6 (promises, new lambda notation) and tools such as Typescript, it starts comparing rather favorably to alternatives. It has the best library support, performance and IDE support of any common scripting language. <|eor|><|sor|>ITT: People who haven't used PHP since version 4.<|eor|><|eols|><|endoftext|>
8
lolphp
smog_alado
cprymoh
<|sols|><|sot|>Why would someone who knows how to use closures, generators, etc. bother with PHP?<|eot|><|sol|>http://www.ibm.com/developerworks/opensource/library/wa-php-renewed_1/index.html?ca=drs-<|eol|><|sor|>Wait, I have to declare what variables my function closes over? Shouldn't the PHP compiler be able to....oh...nevermind.<|eor|><|sor|>C++'s lambda's do the same thing. Any idea why the compiler can't figure it out?<|eor|><|sor|>It does with this syntax: `(/* arguments */)[&]{ /* statements */ }`<|eor|><|sor|>don't forget `[=]` for pass-by-value and specifying each closure's closing type like `[foo, &bar]` or pass-by-reference all then specific pass-by-value`[&,bar]` Lots of options.<|eor|><|sor|>> Lots of options Typical C++, eh?<|eor|><|eols|><|endoftext|>
8
lolphp
HiddenKrypt
cprt19q
<|sols|><|sot|>Why would someone who knows how to use closures, generators, etc. bother with PHP?<|eot|><|sol|>http://www.ibm.com/developerworks/opensource/library/wa-php-renewed_1/index.html?ca=drs-<|eol|><|sor|>> Anonymous functions reign supreme in JavaScript, and PHP programmers who don't also know JavaScript are rare. So it was natural for PHP to evolve to include anonymous functions You know things are really fucked up when your programming language has Javascript as a positive role model and a source of inspiration. > If you're used to working with closures in JavaScript, then you're already familiar with their power, flexibility, and *sometimes dangerous nature*. I wonder why he thinks closures are somehow inherently dangerous. At worse its a simpler version of OOP with less room for you to shoot yourself on the foot.<|eor|><|sor|>Javascript is *exactly* the sort of language PHP should have as a role model. Seriously, it's an inspiration. It came from similar roots as PHP (too many cooks, inconsistent design direction) And was (rightly at the time) saddled with a terrible reputation. But it persevered. It changed, and for the better. The "use strict" pragma alone really cleans up the language, and ES6 is a huge change in the direction of a good language design. Unfortunately, I think you're wrong. PHP isn't using Javascript as an inspiration. Javascript has gotten better largely by attempts to define a [subset of the language](http://i.imgur.com/wR3ZxfB.jpg) worth working with, while carefully introducing new features that mesh well with the existign direction the language has been facing. PHP has been trying to find "The Good Parts" by running out and stealing every little feature they think is missing, all while failing to recognize that it's not what they lack, it's what they *have* that sucks. <|eor|><|sor|>[deleted]<|eor|><|sor|>Javascript has inheritance, it's just wrapped in that strange prototype chain thing. ES6 is adding traditional style class declarations. Personally though, I find that a functional programming perspective makes those features a bit unnecessary. <|eor|><|sor|>[deleted]<|eor|><|sor|>What? Oh sorry, was I supposed to be an asshole when you brought up a paradigm? Sorry, my bad. Here, let me try: > JavaScript's twisted ideas of OOP and inheritance BWOOP BWOOP OBJECT ORIENTED HIPSTER DETECTED But seriously, in javascript objects don't have private members. If you want protected variables, you have to use a closure. From an object oriented design perspective this is absolutely a weakness in the language, but from a functional design perspective, it's fine. It's almost like you'll always have a better time trying to use the language for the paradigm it was designed for. <|eor|><|eols|><|endoftext|>
8
lolphp
porkslow
2lyif9
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|eols|><|endoftext|>
29
lolphp
InconsiderateBastard
clzjh45
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Seriously, is there a legit use case for == and != instead of their type safe versions? I rarely use weakly typed languages and I never really understood the point of it all. Why would I want the string "123" and the integer 123 to compare as equals?<|eor|><|sor|>I think arguably it could be useful with collection types (i.e. comparing a list to an array), but the way that php handles numerical string comparisons is kinda nuts.<|eor|><|sor|>"That string looks like an integer. That integer looks too big. Better make it a float."<|eor|><|eols|><|endoftext|>
21
lolphp
DoctorWaluigiTime
clzc2qf
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Personally, I'm in favor of silently modifying `==` and `!=` to behave exactly like `===` and `!==` respectively. That or just removing them from the language altogether, so people can fix their stuffs by leaning on the compiler (i.e. getting parser errors). While I'm in dream land, let's do the same thing for JavaScript too.<|eor|><|eols|><|endoftext|>
20
lolphp
willglynn
cm054y1
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Seriously, is there a legit use case for == and != instead of their type safe versions? I rarely use weakly typed languages and I never really understood the point of it all. Why would I want the string "123" and the integer 123 to compare as equals?<|eor|><|sor|>For == no but for != I would say yes. Sometimes you just want to do if (!something) and you really don't care if it's null, undefined, false, etc.<|eor|><|sor|>To quote the brilliant [Douglas Crockford](https://www.youtube.com/watch?v=taaEzHI9xyY): >I am not saying that it isnt useful, I am saying that there is never a case where it isnt confusing Looking at that isolated line of code, my first thought is that you just want to see if the value is false. Or did you mean that something couldn't be 0? Or the empty string? Or an empty array? Or the string '0'? This is the problem of using constructs in the language that doesn't display the explicit intent of the programmer. Always be explicit about what the code should do by using things like ===. That way you'll avoid hard to find bugs, and it'll be easier for someone to know what you wanted to do.<|eor|><|sor|>That's what comments are for. == is faster than ===, and you can't control the type of data if you don't control the source, and sometimes you don't want to because you are trying to do some sort of real-world application.<|eor|><|sor|>> == is faster than === Seriously? First, why do you care about performance are equality comparisons actually a bottleneck? Second, even if that's true, is performance really more important than correctness? > you can't control the type of data if you don't control the source And if the source supplies the wrong type, it should fail instead of succeeding in unexpected ways. What's more, `==` botches comparisons even with identical types on both ends: `"1e2" == "100"`, for example. Sure you gave it two strings, but you really meant for them to be compared numerically, right? > sometimes you don't want to [control the type] because you are trying to do some sort of real-world application Ah yes, all those real-world applications where edge cases don't matter, and certainly never cause significant bugs.<|eor|><|eols|><|endoftext|>
12
lolphp
jadkik94
clztsti
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Personally, I'm in favor of silently modifying `==` and `!=` to behave exactly like `===` and `!==` respectively. That or just removing them from the language altogether, so people can fix their stuffs by leaning on the compiler (i.e. getting parser errors). While I'm in dream land, let's do the same thing for JavaScript too.<|eor|><|sor|>I'm for replacing Javascript with Lua, and finding a saner language than PHP for server-side stuff.<|eor|><|sor|>I'd vote for python on both sides. You can say I'm a dreamer but I'm not the only one!<|eor|><|eols|><|endoftext|>
10
lolphp
recaph
clzn7m6
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Seriously, is there a legit use case for == and != instead of their type safe versions? I rarely use weakly typed languages and I never really understood the point of it all. Why would I want the string "123" and the integer 123 to compare as equals?<|eor|><|sor|>For == no but for != I would say yes. Sometimes you just want to do if (!something) and you really don't care if it's null, undefined, false, etc.<|eor|><|sor|>To quote the brilliant [Douglas Crockford](https://www.youtube.com/watch?v=taaEzHI9xyY): >I am not saying that it isnt useful, I am saying that there is never a case where it isnt confusing Looking at that isolated line of code, my first thought is that you just want to see if the value is false. Or did you mean that something couldn't be 0? Or the empty string? Or an empty array? Or the string '0'? This is the problem of using constructs in the language that doesn't display the explicit intent of the programmer. Always be explicit about what the code should do by using things like ===. That way you'll avoid hard to find bugs, and it'll be easier for someone to know what you wanted to do.<|eor|><|eols|><|endoftext|>
10
lolphp
Regimardyl
clzh1tr
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Personally, I'm in favor of silently modifying `==` and `!=` to behave exactly like `===` and `!==` respectively. That or just removing them from the language altogether, so people can fix their stuffs by leaning on the compiler (i.e. getting parser errors). While I'm in dream land, let's do the same thing for JavaScript too.<|eor|><|sor|>I'm for replacing Javascript with Lua, and finding a saner language than PHP for server-side stuff.<|eor|><|eols|><|endoftext|>
9
lolphp
tdammers
clzoj7i
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Seriously, is there a legit use case for == and != instead of their type safe versions? I rarely use weakly typed languages and I never really understood the point of it all. Why would I want the string "123" and the integer 123 to compare as equals?<|eor|><|sor|>The point is that PHP is a ~~language~~ scripting tool for the web: the legit use case is whipping up a small, quick-and-dirty web page with a bit of dynamic content in it, and since the web is all textual, taking shortcuts like these is somewhat excusable in this scenario. If you want correct code, or stuff that scales well beyond three files and 100 lines of code, PHP not your friend, but if you need to whip up a simple little tool in 5 minutes and deploy it to a standard server without installing 27 dependencies, that's where PHP shines. So, basically, you want to do stuff like `$foo = $_GET['a']; $bar = $_GET['b']; if ($foo > 23) { echo $foo + $bar; } elseif ($foo == 0) { echo $bar; } else { echo "Nah, let's not, shall we?"; }` Which, incidentally, contains a serious and embarrassing security flaw, so go figure.<|eor|><|eols|><|endoftext|>
9
lolphp
suspiciously_calm
clzyzk8
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Personally, I'm in favor of silently modifying `==` and `!=` to behave exactly like `===` and `!==` respectively. That or just removing them from the language altogether, so people can fix their stuffs by leaning on the compiler (i.e. getting parser errors). While I'm in dream land, let's do the same thing for JavaScript too.<|eor|><|sor|>I'm for replacing Javascript with Lua, and finding a saner language than PHP for server-side stuff.<|eor|><|sor|>> I'm for replacing Javascript with Lua Seconded. > finding a saner language than PHP for server-side stuff Ruby?<|eor|><|eols|><|endoftext|>
8
lolphp
implicit_cast
clzorwl
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Personally, I'm in favor of silently modifying `==` and `!=` to behave exactly like `===` and `!==` respectively. That or just removing them from the language altogether, so people can fix their stuffs by leaning on the compiler (i.e. getting parser errors). While I'm in dream land, let's do the same thing for JavaScript too.<|eor|><|sor|>I think == and != should be deleted from the language entirely. Using them should become a syntax error. From a migration perspective, this is as good as we're likely to get: People would be forced to update their code to do the right thing, but they wouldn't have to worry about pre-existing code changing behaviour underneath them.<|eor|><|eols|><|endoftext|>
7
lolphp
captainramen
clzizo5
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Seriously, is there a legit use case for == and != instead of their type safe versions? I rarely use weakly typed languages and I never really understood the point of it all. Why would I want the string "123" and the integer 123 to compare as equals?<|eor|><|sor|>For == no but for != I would say yes. Sometimes you just want to do if (!something) and you really don't care if it's null, undefined, false, etc.<|eor|><|eols|><|endoftext|>
7
lolphp
vytah
cm07olc
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Personally, I'm in favor of silently modifying `==` and `!=` to behave exactly like `===` and `!==` respectively. That or just removing them from the language altogether, so people can fix their stuffs by leaning on the compiler (i.e. getting parser errors). While I'm in dream land, let's do the same thing for JavaScript too.<|eor|><|sor|>I'm for replacing Javascript with Lua, and finding a saner language than PHP for server-side stuff.<|eor|><|sor|>I'd vote for python on both sides. You can say I'm a dreamer but I'm not the only one!<|eor|><|sor|>Can't be minified due to the syntax, thus would never be suitable for front end work.<|eor|><|sor|>It can be minified, it's just the minification would have to preserve indentation. I wonder what would be the results though.<|eor|><|eols|><|endoftext|>
7
lolphp
Dworgi
cm07z25
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Seriously, is there a legit use case for == and != instead of their type safe versions? I rarely use weakly typed languages and I never really understood the point of it all. Why would I want the string "123" and the integer 123 to compare as equals?<|eor|><|sor|>For == no but for != I would say yes. Sometimes you just want to do if (!something) and you really don't care if it's null, undefined, false, etc.<|eor|><|sor|>To quote the brilliant [Douglas Crockford](https://www.youtube.com/watch?v=taaEzHI9xyY): >I am not saying that it isnt useful, I am saying that there is never a case where it isnt confusing Looking at that isolated line of code, my first thought is that you just want to see if the value is false. Or did you mean that something couldn't be 0? Or the empty string? Or an empty array? Or the string '0'? This is the problem of using constructs in the language that doesn't display the explicit intent of the programmer. Always be explicit about what the code should do by using things like ===. That way you'll avoid hard to find bugs, and it'll be easier for someone to know what you wanted to do.<|eor|><|sor|>That's what comments are for. == is faster than ===, and you can't control the type of data if you don't control the source, and sometimes you don't want to because you are trying to do some sort of real-world application.<|eor|><|sor|>> == is faster than === Seriously? First, why do you care about performance are equality comparisons actually a bottleneck? Second, even if that's true, is performance really more important than correctness? > you can't control the type of data if you don't control the source And if the source supplies the wrong type, it should fail instead of succeeding in unexpected ways. What's more, `==` botches comparisons even with identical types on both ends: `"1e2" == "100"`, for example. Sure you gave it two strings, but you really meant for them to be compared numerically, right? > sometimes you don't want to [control the type] because you are trying to do some sort of real-world application Ah yes, all those real-world applications where edge cases don't matter, and certainly never cause significant bugs.<|eor|><|sor|>> is performance really more important than correctness? First, they are both correct.. Context is a reality. Second, performance is imprortant in large-scale, high-volume operations. >And if the source supplies the wrong type, it should fail instead of succeeding in unexpected ways. You have no fucking idea what the fuck you are talking about. There are plenty of systems where the systems don't control the data, such as websites with user inputs, especially in real-time, and things which must capture all data properly no matter what are a real system. To put it in a way that even you might understand: sometimes there is no "wrong" type. Holy shit are you stupid. What's more, you compare two strings which aren't typecast as anything and expect them to be compared as something other than strings. Those aren't numerical values: those are string representations of numerical values: you have them encapsulated in quotation marks. And, further, they aren't of the same numerical datatype, either, which would further prevent the type of comparison you want to perform because you don't understand datatypes. Because of the context of two string value representations of two numerical values of two disparate numerical value types if you want to compare those as numerical values you must typecast them. If one value was not explicitly a string then the comparison would implicitly compare them with their common datatype. You just don't understand either datatypes nor typecasting nor data comparison operations. >Ah yes, all those real-world applications where edge cases don't matter, and certainly never cause significant bugs. I have already shown that these aren't bugs but rather very elaborate, sophisticated and highly structured contextual features. And such comparisons are not edge cases when you know how to properly handle such circumstances. You just suck at programming and system design. e: Oh, also "1e2"=="100" does resolve to 1. === does not. One is float, the other is int, and both are string representations.<|eor|><|sor|>There's always a wrong type, and if you really look at your use cases you'll realise that there's only ever one right type. What it is obviously depends on the source, but there's always a wrong way to interpret data. A username field with "1e4" in it probably shouldn't compare with the integer 10,000. The biggest lie in programming is that weak typing is useful. Every style guide for Python tells you to pretend you have strong typing. <|eor|><|eols|><|endoftext|>
7
lolphp
_vec_
cm0o2ie
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Seriously, is there a legit use case for == and != instead of their type safe versions? I rarely use weakly typed languages and I never really understood the point of it all. Why would I want the string "123" and the integer 123 to compare as equals?<|eor|><|sor|>For == no but for != I would say yes. Sometimes you just want to do if (!something) and you really don't care if it's null, undefined, false, etc.<|eor|><|sor|>To quote the brilliant [Douglas Crockford](https://www.youtube.com/watch?v=taaEzHI9xyY): >I am not saying that it isnt useful, I am saying that there is never a case where it isnt confusing Looking at that isolated line of code, my first thought is that you just want to see if the value is false. Or did you mean that something couldn't be 0? Or the empty string? Or an empty array? Or the string '0'? This is the problem of using constructs in the language that doesn't display the explicit intent of the programmer. Always be explicit about what the code should do by using things like ===. That way you'll avoid hard to find bugs, and it'll be easier for someone to know what you wanted to do.<|eor|><|sor|>That's what comments are for. == is faster than ===, and you can't control the type of data if you don't control the source, and sometimes you don't want to because you are trying to do some sort of real-world application.<|eor|><|sor|>> == is faster than === First of all, I don't believe you. `==` simply does more work than `===`. Even if PHP doesn't care about types the underlying C-based interpreter has to. And while type coercions in C are relatively cheap, they're a hell of a lot more expensive than dumb value comparisons. Second, even when microoptimizations like this are valid they're usually not worth the trouble. Syntax optimizations usually change the runtime of a function by, at best, a couple of percent. Architectural changes can change runtime by several orders of magnitude. Unnecessarily touching the file system or making an extra database or network request has an even larger impact. In any real program the gains available from syntax optimizations will be dwarfed by other available performance impacts. Third, if you care enough about performance to worry about these changes then *why the fuck are you writing in PHP?!* Modern PHP performs quite well for an interpreted language, but it's not even in the same ballpark as C, C++, Java, and other low-level languages. By choosing a higher level language you've already thrown a huge chunk of your potential raw performance out the window in exchange for clarity, simplicity, and developer productivity. > and you can't control the type of data if you don't control the source Bullshit. HTTP headers are strings. GET and POST values are strings. Console input is a string. The type is 100% predictable. Sometimes I want that input to be a string that I can parse as something else (a number, a filepath, aURL, whatever), but in those cases I still need to parse it explicitly so that I can return reasonable errors. Then, hey, I've already parsed it so now I've got a guaranteed number or what have you that I can use from that point on.<|eor|><|eols|><|endoftext|>
6
lolphp
willglynn
cm0nga6
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>Seriously, is there a legit use case for == and != instead of their type safe versions? I rarely use weakly typed languages and I never really understood the point of it all. Why would I want the string "123" and the integer 123 to compare as equals?<|eor|><|sor|>For == no but for != I would say yes. Sometimes you just want to do if (!something) and you really don't care if it's null, undefined, false, etc.<|eor|><|sor|>To quote the brilliant [Douglas Crockford](https://www.youtube.com/watch?v=taaEzHI9xyY): >I am not saying that it isnt useful, I am saying that there is never a case where it isnt confusing Looking at that isolated line of code, my first thought is that you just want to see if the value is false. Or did you mean that something couldn't be 0? Or the empty string? Or an empty array? Or the string '0'? This is the problem of using constructs in the language that doesn't display the explicit intent of the programmer. Always be explicit about what the code should do by using things like ===. That way you'll avoid hard to find bugs, and it'll be easier for someone to know what you wanted to do.<|eor|><|sor|>That's what comments are for. == is faster than ===, and you can't control the type of data if you don't control the source, and sometimes you don't want to because you are trying to do some sort of real-world application.<|eor|><|sor|>> == is faster than === Seriously? First, why do you care about performance are equality comparisons actually a bottleneck? Second, even if that's true, is performance really more important than correctness? > you can't control the type of data if you don't control the source And if the source supplies the wrong type, it should fail instead of succeeding in unexpected ways. What's more, `==` botches comparisons even with identical types on both ends: `"1e2" == "100"`, for example. Sure you gave it two strings, but you really meant for them to be compared numerically, right? > sometimes you don't want to [control the type] because you are trying to do some sort of real-world application Ah yes, all those real-world applications where edge cases don't matter, and certainly never cause significant bugs.<|eor|><|sor|>The performance argument is usually BS, but what about client side JS applications? Maximising battery life is certainly a non functional requirement. Like any tool in your tool chest, you should be careful about when to use loose typing. You usually shouldn't but sometimes it is ok, especially when dealing with *schemaless* data. BTW, coffee script does not transpile if !f doSomething() to if (false === f) { doSomething() } but does transpile == to ===. I suspect typescript does the same.<|eor|><|sor|>> The performance argument is usually BS, but what about client side JS applications? Maximising battery life is certainly a non functional requirement. And if profiling indicates that a particular operation is consuming a significant amount of time, then I'll look at optimizing it. Even then the performance difference is almost certainly only relevant in a tight loop, in which case the best solution usually involves algorithmic or data structure changes, rather than micro-optimizations that cater to quirks of the current execution environment. > Like any tool in your tool chest, you should be careful about when to use loose typing. It's not even about loose typing. I can accept `1 == "1"` or `"" == false`. PHP's `==` operator, on the other hand, goes out of its way to screw you when you're *careful* about types, like the `"1e2" == "100"` example I mentioned. PHP's "type juggling" means that your string variable won't always be treated as a string, depending on the other values present **even when they are all the same type**. This is a hazard because it means that even proper use of type system (strings for strings, numbers for numbers, booleans for booleans) will result in the language actively subverting you in input-dependent ways. Type juggling is optional for `==` since you can use `===` instead, but it is otherwise pervasive; for example, there is no similar substitute for `<`. Mixing type-safe string equality with type-juggled string comparisons [results in fun](https://bugs.php.net/bug.php?id=47370#1235868692) because e.g. `"10" < "1az"`, `"1az" < "1e1"` and `"1e1" == "10"`. [PHP Sadness](http://phpsadness.com/sad/47) explains one class of bugs caused by this behavior: strings that are *almost always* hexadecimal but very occasionally contain only decimal digits will break when compared with `==`. (Good luck catching that with a test suite.) [PHP #54547](https://bugs.php.net/bug.php?id=54547) contains extended discussion on this point, including: > In that context - in my eyes - this comparison also makes sense. Consider a very similar comparison: > > var_dump('0.1' == '0.10000000'); > > What would you expect to be the output - if you remember that in PHP numeric strings and actual numbers are interchangeable? Clearly it has to behave exactly as if you had written: > > var_dump(0.1 == 0.10000000); // => bool(true) > > In most cases this type of comparison is what you want and it usually works exactly as expected. I cannot disagree with this design more emphatically. I can, however, avoid PHP.<|eor|><|eols|><|endoftext|>
6
lolphp
Dworgi
cm08dvl
<|sols|><|sot|>PHP loose comparison strikes again<|eot|><|sol|>http://blog.laravel.com/csrf-vulnerability-in-laravel-4/<|eol|><|sor|>For == no but for != I would say yes. Sometimes you just want to do if (!something) and you really don't care if it's null, undefined, false, etc.<|eor|><|sor|>To quote the brilliant [Douglas Crockford](https://www.youtube.com/watch?v=taaEzHI9xyY): >I am not saying that it isnt useful, I am saying that there is never a case where it isnt confusing Looking at that isolated line of code, my first thought is that you just want to see if the value is false. Or did you mean that something couldn't be 0? Or the empty string? Or an empty array? Or the string '0'? This is the problem of using constructs in the language that doesn't display the explicit intent of the programmer. Always be explicit about what the code should do by using things like ===. That way you'll avoid hard to find bugs, and it'll be easier for someone to know what you wanted to do.<|eor|><|sor|>That's what comments are for. == is faster than ===, and you can't control the type of data if you don't control the source, and sometimes you don't want to because you are trying to do some sort of real-world application.<|eor|><|sor|>> == is faster than === Seriously? First, why do you care about performance are equality comparisons actually a bottleneck? Second, even if that's true, is performance really more important than correctness? > you can't control the type of data if you don't control the source And if the source supplies the wrong type, it should fail instead of succeeding in unexpected ways. What's more, `==` botches comparisons even with identical types on both ends: `"1e2" == "100"`, for example. Sure you gave it two strings, but you really meant for them to be compared numerically, right? > sometimes you don't want to [control the type] because you are trying to do some sort of real-world application Ah yes, all those real-world applications where edge cases don't matter, and certainly never cause significant bugs.<|eor|><|sor|>> is performance really more important than correctness? First, they are both correct.. Context is a reality. Second, performance is imprortant in large-scale, high-volume operations. >And if the source supplies the wrong type, it should fail instead of succeeding in unexpected ways. You have no fucking idea what the fuck you are talking about. There are plenty of systems where the systems don't control the data, such as websites with user inputs, especially in real-time, and things which must capture all data properly no matter what are a real system. To put it in a way that even you might understand: sometimes there is no "wrong" type. Holy shit are you stupid. What's more, you compare two strings which aren't typecast as anything and expect them to be compared as something other than strings. Those aren't numerical values: those are string representations of numerical values: you have them encapsulated in quotation marks. And, further, they aren't of the same numerical datatype, either, which would further prevent the type of comparison you want to perform because you don't understand datatypes. Because of the context of two string value representations of two numerical values of two disparate numerical value types if you want to compare those as numerical values you must typecast them. If one value was not explicitly a string then the comparison would implicitly compare them with their common datatype. You just don't understand either datatypes nor typecasting nor data comparison operations. >Ah yes, all those real-world applications where edge cases don't matter, and certainly never cause significant bugs. I have already shown that these aren't bugs but rather very elaborate, sophisticated and highly structured contextual features. And such comparisons are not edge cases when you know how to properly handle such circumstances. You just suck at programming and system design. e: Oh, also "1e2"=="100" does resolve to 1. === does not. One is float, the other is int, and both are string representations.<|eor|><|sor|>There's always a wrong type, and if you really look at your use cases you'll realise that there's only ever one right type. What it is obviously depends on the source, but there's always a wrong way to interpret data. A username field with "1e4" in it probably shouldn't compare with the integer 10,000. The biggest lie in programming is that weak typing is useful. Every style guide for Python tells you to pretend you have strong typing. <|eor|><|sor|>> There's always a wrong type Stopped reading there. You are completely wrong. There's OFTEN...<|eor|><|sor|>I repeat: there's always a wrong type. Look, you give me data and tell me where it's going and I'll tell you what type I want to interpret it as and you try to deal with it. Does that sound like fun? Information is never typeless, and relying on PHP (or any other language) to interpret it correctly is madness. Unless you're explicit about how you want to compare things (with ===), your program is buggy. You may not know about it yet, but it fundamentally is because when you're not sure what you're comparing to what, you open up the entirety of the language's edge cases - null, 0, "", "0", [] - all of which work slightly differently. And that disregards the fact that there's never a case when the type of input data is not known. You have a textbox, you know where that's going. You have an XML/JSON document, you know what type of information is in each attribute, or something is going wrong somewhere. It is always better to fail quickly and fail loudly than to silently do something unexpected.<|eor|><|eols|><|endoftext|>
6
lolphp
pegasus_527
284vid
<|sols|><|sot|>filter_var($address, FILTER_VALIDATE_EMAIL) does not validate email addresses correctly<|eot|><|sol|>http://php.net/manual/en/function.filter-var.php#112492<|eol|><|eols|><|endoftext|>
33
lolphp
xiongchiamiov
ci7ezl2
<|sols|><|sot|>filter_var($address, FILTER_VALIDATE_EMAIL) does not validate email addresses correctly<|eot|><|sol|>http://php.net/manual/en/function.filter-var.php#112492<|eol|><|sor|>[isemail]( https://code.google.com/p/isemail/ ) is the only library I'm aware of that handles all the crazy things no one uses. I wouldn't be surprised to find cases not supported in any other language's stdlib.<|eor|><|eols|><|endoftext|>
22
lolphp
phoshi
ci7jgxt
<|sols|><|sot|>filter_var($address, FILTER_VALIDATE_EMAIL) does not validate email addresses correctly<|eot|><|sol|>http://php.net/manual/en/function.filter-var.php#112492<|eol|><|sor|>Is this really lol? I'd assume they chose to implement the path of least resistance and for the majority use cases. Anyone who uses filter_var() for validating email is most likely just validating a user signup, and doesn't want to allow those kinds of emails.<|eor|><|sor|>but all of them are perfectly valid! Okay, so maybe you don't want `"()<>[]:,;@\"\\!#$%&'*+-/=?^_``{}| ~.a"@example.org`, but you /certainly/ want to be able to have `admin@mailserver1`. Email validation is a hard problem, but the halfway solutions just don't work. Either actually send the email, or just sanity check there's an @ in it or something. All or nothing is the only way here, otherwise you just end up needlessly restricting completely valid addresses.<|eor|><|eols|><|endoftext|>
13
lolphp
xiongchiamiov
ci7j53f
<|sols|><|sot|>filter_var($address, FILTER_VALIDATE_EMAIL) does not validate email addresses correctly<|eot|><|sol|>http://php.net/manual/en/function.filter-var.php#112492<|eol|><|sor|>[isemail]( https://code.google.com/p/isemail/ ) is the only library I'm aware of that handles all the crazy things no one uses. I wouldn't be surprised to find cases not supported in any other language's stdlib.<|eor|><|sor|>Just send a damn email. It's not like they cost or something. <|eor|><|sor|>Agreed; if you want to verify it's a real address, this is the only real solution.<|eor|><|eols|><|endoftext|>
11
lolphp
gearvOsh
ci7hyvm
<|sols|><|sot|>filter_var($address, FILTER_VALIDATE_EMAIL) does not validate email addresses correctly<|eot|><|sol|>http://php.net/manual/en/function.filter-var.php#112492<|eol|><|sor|>Is this really lol? I'd assume they chose to implement the path of least resistance and for the majority use cases. Anyone who uses filter_var() for validating email is most likely just validating a user signup, and doesn't want to allow those kinds of emails.<|eor|><|eols|><|endoftext|>
8
lolphp
raylu
ci7p8dc
<|sols|><|sot|>filter_var($address, FILTER_VALIDATE_EMAIL) does not validate email addresses correctly<|eot|><|sol|>http://php.net/manual/en/function.filter-var.php#112492<|eol|><|sor|>Is this really lol? I'd assume they chose to implement the path of least resistance and for the majority use cases. Anyone who uses filter_var() for validating email is most likely just validating a user signup, and doesn't want to allow those kinds of emails.<|eor|><|sor|>but all of them are perfectly valid! Okay, so maybe you don't want `"()<>[]:,;@\"\\!#$%&'*+-/=?^_``{}| ~.a"@example.org`, but you /certainly/ want to be able to have `admin@mailserver1`. Email validation is a hard problem, but the halfway solutions just don't work. Either actually send the email, or just sanity check there's an @ in it or something. All or nothing is the only way here, otherwise you just end up needlessly restricting completely valid addresses.<|eor|><|sor|>This is hardly a problem with PHP, I expect very few sites will allow "admin@mailserver1." or any of the more exotic email addresses.<|eor|><|sor|>This is a problem with email validation in general. That address is 100% valid, as per the spec, and it *should* be allowed. Not allowing it should be classified as a bug.<|eor|><|sor|>It should not be allowed if you're letting someone sign up on your website with that address. Your mailserver will never be able to send mail to a domain it can't resolve.<|eor|><|eols|><|endoftext|>
8
lolphp
captainramen
ci80bly
<|sols|><|sot|>filter_var($address, FILTER_VALIDATE_EMAIL) does not validate email addresses correctly<|eot|><|sol|>http://php.net/manual/en/function.filter-var.php#112492<|eol|><|sor|>Is this really lol? I'd assume they chose to implement the path of least resistance and for the majority use cases. Anyone who uses filter_var() for validating email is most likely just validating a user signup, and doesn't want to allow those kinds of emails.<|eor|><|sor|>but all of them are perfectly valid! Okay, so maybe you don't want `"()<>[]:,;@\"\\!#$%&'*+-/=?^_``{}| ~.a"@example.org`, but you /certainly/ want to be able to have `admin@mailserver1`. Email validation is a hard problem, but the halfway solutions just don't work. Either actually send the email, or just sanity check there's an @ in it or something. All or nothing is the only way here, otherwise you just end up needlessly restricting completely valid addresses.<|eor|><|sor|>This is hardly a problem with PHP, I expect very few sites will allow "admin@mailserver1." or any of the more exotic email addresses.<|eor|><|sor|>This is a problem with email validation in general. That address is 100% valid, as per the spec, and it *should* be allowed. Not allowing it should be classified as a bug.<|eor|><|sor|>It should not be allowed if you're letting someone sign up on your website with that address. Your mailserver will never be able to send mail to a domain it can't resolve.<|eor|><|sor|>Ignoring that php is often used for internal applications where internal mail servers very much are accessible, that also blocks addresses on TLDs which, while rare, is not unheard of. <|eor|><|sor|>Sure, but if that's the case the input is probably trusted and you don't need to do any validation anyway. That's just not the intended use case for this function.<|eor|><|sor|>Input? Trusted? Is that a joke or...? you never trust user input. Ever.<|eor|><|eols|><|endoftext|>
6
lolphp
phoshi
ci7mkgo
<|sols|><|sot|>filter_var($address, FILTER_VALIDATE_EMAIL) does not validate email addresses correctly<|eot|><|sol|>http://php.net/manual/en/function.filter-var.php#112492<|eol|><|sor|>Is this really lol? I'd assume they chose to implement the path of least resistance and for the majority use cases. Anyone who uses filter_var() for validating email is most likely just validating a user signup, and doesn't want to allow those kinds of emails.<|eor|><|sor|>but all of them are perfectly valid! Okay, so maybe you don't want `"()<>[]:,;@\"\\!#$%&'*+-/=?^_``{}| ~.a"@example.org`, but you /certainly/ want to be able to have `admin@mailserver1`. Email validation is a hard problem, but the halfway solutions just don't work. Either actually send the email, or just sanity check there's an @ in it or something. All or nothing is the only way here, otherwise you just end up needlessly restricting completely valid addresses.<|eor|><|sor|>This is hardly a problem with PHP, I expect very few sites will allow "admin@mailserver1." or any of the more exotic email addresses.<|eor|><|sor|>This is a problem with email validation in general. That address is 100% valid, as per the spec, and it *should* be allowed. Not allowing it should be classified as a bug.<|eor|><|eols|><|endoftext|>
5
lolphp
GranPC
26bk6m
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|eols|><|endoftext|>
30
lolphp
duskwuff
chpmbvd
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>Blame gd for this one. Not PHP's fault the library they're providing bindings to is crazy.<|eor|><|eols|><|endoftext|>
22
lolphp
RecursionIsRecursion
chpl9hk
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>$im,$i,$i,$i... He was just trying to spell Mississippi.<|eor|><|eols|><|endoftext|>
18
lolphp
Darkimmortal
chpl5u9
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>So that's 7-bits for the alpha channel. Is this because all ints in php are signed? But that still doesn't explain why 0 is opaque...<|eor|><|sor|>0 for opaque is far from unheard of outside of web stuff edit: as is 7 bit alpha<|eor|><|eols|><|endoftext|>
14
lolphp
sloat
chpik8b
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>So that's 7-bits for the alpha channel. Is this because all ints in php are signed? But that still doesn't explain why 0 is opaque...<|eor|><|eols|><|endoftext|>
13
lolphp
barubary
chq0qmh
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>> imagecolorallocatealpha dat function name<|eor|><|sor|>"Fortunately" PHP is case insensitive half the time, so you can call it as ImageColorAllocateAlpha (if you want).<|eor|><|eols|><|endoftext|>
8
lolphp
Serialk
chq15hi
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>> imagecolorallocatealpha dat function name<|eor|><|sor|>"Fortunately" PHP is case insensitive half the time, so you can call it as ImageColorAllocateAlpha (if you want).<|eor|><|sor|>Of course, that's except if you're using an exotic locale, because *obviously*, capitalization of function names depends of it.<|eor|><|eols|><|endoftext|>
8
lolphp
barubary
chqls93
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>> imagecolorallocatealpha dat function name<|eor|><|sor|>"Fortunately" PHP is case insensitive half the time, so you can call it as ImageColorAllocateAlpha (if you want).<|eor|><|sor|>Of course, that's except if you're using an exotic locale, because *obviously*, capitalization of function names depends of it.<|eor|><|sor|>Yeah, if your web server is running in a Turkish locale, you have to use mageColorAllocateAlpha, I guess.<|eor|><|eols|><|endoftext|>
8
lolphp
Slippery_John
chpy6ek
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>> imagecolorallocatealpha dat function name<|eor|><|eols|><|endoftext|>
7
lolphp
duskwuff
chq25x9
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>Blame gd for this one. Not PHP's fault the library they're providing bindings to is crazy.<|eor|><|sor|>You could argue that only bad languages provide default bindings for bad libraries though. ;)<|eor|><|sor|>I'm not convinced there are *any* good image manipulation libraries available. The other big one out there is ImageMagick (and GraphicsMagick, which is very similar), and it's awful in its own ways.<|eor|><|eols|><|endoftext|>
7
lolphp
duskwuff
chq5htk
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>Blame gd for this one. Not PHP's fault the library they're providing bindings to is crazy.<|eor|><|sor|>You could argue that only bad languages provide default bindings for bad libraries though. ;)<|eor|><|sor|>I'm not convinced there are *any* good image manipulation libraries available. The other big one out there is ImageMagick (and GraphicsMagick, which is very similar), and it's awful in its own ways.<|eor|><|sor|>Pythons PIL or Pillow are pretty good.<|eor|><|sor|>PIL isn't all that great either, I'm afraid! The authors of PIL made some really weird decisions (e.g, implementing PNG support in pure Python, rather than using libpng), and that's resulted in some weird deficiencies (e.g, PIL can't read interlaced PNGs). I haven't used Pillow, so I can't speak to its quality.<|eor|><|eols|><|endoftext|>
7
lolphp
CrypticOctagon
chpqocq
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>This is actually not half as annoying as GD's inability to transform transparent images.<|eor|><|eols|><|endoftext|>
6
lolphp
Serialk
chq1f3s
<|sols|><|sot|>A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.<|eot|><|sol|>http://www.php.net/manual/en/function.imagecolorallocatealpha.php<|eol|><|sor|>Blame gd for this one. Not PHP's fault the library they're providing bindings to is crazy.<|eor|><|sor|>You could argue that only bad languages provide default bindings for bad libraries though. ;)<|eor|><|eols|><|endoftext|>
6
lolphp
deadstone
1qos6m
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|eoss|><|endoftext|>
28
lolphp
catcradle5
cdf7lr4
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>You have to admit it fits well within the PHP philosophy, though...<|eor|><|sor|>Just enable the "show usernames" boolean. Why does the function need that boolean? For feature compatibility with PHP 2.0 <|eor|><|sor|>Boolean? Hah. No, you need to do `ini_set("show_comment_usernames_and_dates", "on")`. No true or false here. But be sure to include it at the top of every file because .htaccess defaults it to "off"! Though on some configurations this won't be the case and it'll be in php.ini instead of .htaccess. And there it may default to on or off. So be sure to check the default in both php.ini and .htaccess. Also in older versions the setting doesn't exist, in which case you can set it with the superglobal `$HTTP_DONT_HIDE_COMMENT_USERNAMES_AND_DATES` but this is deprecated in versions that are still too old to have the ini setting but new enough to use one of the standard superglobal arrays, in which case you can then just use `$_SESSION['DONT_HIDE_COMMENT_USERNAMES_AND_DATES']`. Even though it's deprecated the old superglobal will still take effect and will actually take precedence over the session variable so be careful! And if the session doesn't exist yet you'll need to create a stub session for every user, even unregistered ones. Note that these are all deprecated in PHP 5.7 though, in which case you'll need to use `show_usernames_and_dates()`. But this may not work as expected because it acts as a NO-OP if the value is already set in php.ini or apache.conf or apache2.conf (sometimes httpd.conf) or your `sites-enabled` vhost config file or .htaccess or a previous `ini_set()`, despite all those being deprecated for the setting, so you'll need to use `show_usernames_and_dates(true)`, "true" of course meaning "force" in this case. Though unfortunately someone found a security flaw in it the day it was shipped so now in 5.7.1 you must ALWAYS be sure to use `real_show_usernames_and_dates()`. The API changed though so if you pass `real_show_usernames_and_dates(true)` it will actually show only the usernames, NOT the dates, as the signature is now `real_show_usernames_and_dates($onlyUsernames, $force)` so for the old behavior you'll have to use `real_show_usernames_and_dates(false, true)`. Also, to simplify usage (having both "on" and "off" as settings in the past were of course confusing for many beginners): once you call it, there is no way to reverse it. Well you can, because the function call actually just sets a name-mangled session variable, so you could change the value of that variable or just destroy and recreate the session, but we don't recommend this. But someone in the documentation comments will probably give you a code snippet you can use to do this. And this is all in the documentation, so you're a blithering idiot if you think this is confusing behavior.<|eor|><|eoss|><|endoftext|>
88
lolphp
ironhand
cdexbnd
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>You have to admit it fits well within the PHP philosophy, though...<|eor|><|eoss|><|endoftext|>
34
lolphp
deadstone
cdf26zd
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>You have to admit it fits well within the PHP philosophy, though...<|eor|><|sor|>Just enable the "show usernames" boolean. Why does the function need that boolean? For feature compatibility with PHP 2.0 <|eor|><|soopr|>Jesus christ, you couldn't be more wrong! It's "real_show_usernames".<|eoopr|><|eoss|><|endoftext|>
29
lolphp
deadstone
cdfl81q
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>You have to admit it fits well within the PHP philosophy, though...<|eor|><|sor|>Just enable the "show usernames" boolean. Why does the function need that boolean? For feature compatibility with PHP 2.0 <|eor|><|sor|>Boolean? Hah. No, you need to do `ini_set("show_comment_usernames_and_dates", "on")`. No true or false here. But be sure to include it at the top of every file because .htaccess defaults it to "off"! Though on some configurations this won't be the case and it'll be in php.ini instead of .htaccess. And there it may default to on or off. So be sure to check the default in both php.ini and .htaccess. Also in older versions the setting doesn't exist, in which case you can set it with the superglobal `$HTTP_DONT_HIDE_COMMENT_USERNAMES_AND_DATES` but this is deprecated in versions that are still too old to have the ini setting but new enough to use one of the standard superglobal arrays, in which case you can then just use `$_SESSION['DONT_HIDE_COMMENT_USERNAMES_AND_DATES']`. Even though it's deprecated the old superglobal will still take effect and will actually take precedence over the session variable so be careful! And if the session doesn't exist yet you'll need to create a stub session for every user, even unregistered ones. Note that these are all deprecated in PHP 5.7 though, in which case you'll need to use `show_usernames_and_dates()`. But this may not work as expected because it acts as a NO-OP if the value is already set in php.ini or apache.conf or apache2.conf (sometimes httpd.conf) or your `sites-enabled` vhost config file or .htaccess or a previous `ini_set()`, despite all those being deprecated for the setting, so you'll need to use `show_usernames_and_dates(true)`, "true" of course meaning "force" in this case. Though unfortunately someone found a security flaw in it the day it was shipped so now in 5.7.1 you must ALWAYS be sure to use `real_show_usernames_and_dates()`. The API changed though so if you pass `real_show_usernames_and_dates(true)` it will actually show only the usernames, NOT the dates, as the signature is now `real_show_usernames_and_dates($onlyUsernames, $force)` so for the old behavior you'll have to use `real_show_usernames_and_dates(false, true)`. Also, to simplify usage (having both "on" and "off" as settings in the past were of course confusing for many beginners): once you call it, there is no way to reverse it. Well you can, because the function call actually just sets a name-mangled session variable, so you could change the value of that variable or just destroy and recreate the session, but we don't recommend this. But someone in the documentation comments will probably give you a code snippet you can use to do this. And this is all in the documentation, so you're a blithering idiot if you think this is confusing behavior.<|eor|><|soopr|>...You get some gold.<|eoopr|><|eoss|><|endoftext|>
14
lolphp
alx5000
cdex3mj
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>Plus, it doesn't work in other Reddit clients (such as Reddit is fun). Boggles the mind...<|eor|><|eoss|><|endoftext|>
13
lolphp
h2ooooooo
cdexm70
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>I always thought that it was to "save" people from complete PHP fanboys that disagree that PHP has any problems at all, and hence would rage and PM the people posting.<|eor|><|eoss|><|endoftext|>
11
lolphp
seiyria
cdfb0j8
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>The reasoning I was given when this was asked last time, is that it's because we don't care about the people discussing the language, so much as we care about the shortcomings or failures of the language itself, and focusing on the individuals discussing it is not proper.<|eor|><|eoss|><|endoftext|>
8
lolphp
suspiciously_calm
cdf9e0w
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>I always thought that it was to "save" people from complete PHP fanboys that disagree that PHP has any problems at all, and hence would rage and PM the people posting.<|eor|><|sor|>Save? That would be hilarious!<|eor|><|eoss|><|endoftext|>
7
lolphp
seiyria
cdffcpf
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>The reasoning I was given when this was asked last time, is that it's because we don't care about the people discussing the language, so much as we care about the shortcomings or failures of the language itself, and focusing on the individuals discussing it is not proper.<|eor|><|sor|>I posted the above comment a few hours ago, but I've since changed my mind. You can ignore this, sorry guys!<|eor|><|sor|>I changed my mind again, just FYI! <|eor|><|eoss|><|endoftext|>
7
lolphp
suspiciously_calm
cdf9clo
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>You have to admit it fits well within the PHP philosophy, though...<|eor|><|sor|>Just enable the "show usernames" boolean. Why does the function need that boolean? For feature compatibility with PHP 2.0 <|eor|><|sor|>Boolean? Hah. No, you need to do `ini_set("show_comment_usernames_and_dates", "on")`. No true or false here. But be sure to include it at the top of every file because .htaccess defaults it to "off"! Though on some configurations this won't be the case and it'll be in php.ini instead of .htaccess. And there it may default to on or off. So be sure to check the default in both php.ini and .htaccess. Also in older versions the setting doesn't exist, in which case you can set it with the superglobal `$HTTP_DONT_HIDE_COMMENT_USERNAMES_AND_DATES` but this is deprecated in versions that are still too old to have the ini setting but new enough to use one of the standard superglobal arrays, in which case you can then just use `$_SESSION['DONT_HIDE_COMMENT_USERNAMES_AND_DATES']`. Even though it's deprecated the old superglobal will still take effect and will actually take precedence over the session variable so be careful! And if the session doesn't exist yet you'll need to create a stub session for every user, even unregistered ones. Note that these are all deprecated in PHP 5.7 though, in which case you'll need to use `show_usernames_and_dates()`. But this may not work as expected because it acts as a NO-OP if the value is already set in php.ini or apache.conf or apache2.conf (sometimes httpd.conf) or your `sites-enabled` vhost config file or .htaccess or a previous `ini_set()`, despite all those being deprecated for the setting, so you'll need to use `show_usernames_and_dates(true)`, "true" of course meaning "force" in this case. Though unfortunately someone found a security flaw in it the day it was shipped so now in 5.7.1 you must ALWAYS be sure to use `real_show_usernames_and_dates()`. The API changed though so if you pass `real_show_usernames_and_dates(true)` it will actually show only the usernames, NOT the dates, as the signature is now `real_show_usernames_and_dates($onlyUsernames, $force)` so for the old behavior you'll have to use `real_show_usernames_and_dates(false, true)`. Also, to simplify usage (having both "on" and "off" as settings in the past were of course confusing for many beginners): once you call it, there is no way to reverse it. Well you can, because the function call actually just sets a name-mangled session variable, so you could change the value of that variable or just destroy and recreate the session, but we don't recommend this. But someone in the documentation comments will probably give you a code snippet you can use to do this. And this is all in the documentation, so you're a blithering idiot if you think this is confusing behavior.<|eor|><|sor|>Of course, if you `ini_set("show_comment_usernames_and_dates", true)` (or `false`), it won't complain, but will randomly interpret it as either "on" or "off." Unless `$GET['override_show_comment_usernames_and_dates']` is set, which overrides the ini setting. Unless you `ini_set("disable_override_show_comment_usernames_and_dates", true)`. This one is a boolean. Using either "on" or "off" (or any other string) will not produce an error, but will be interpreted as `false`.<|eor|><|eoss|><|endoftext|>
6
lolphp
RoadieRich
cdm57sa
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>You have to admit it fits well within the PHP philosophy, though...<|eor|><|sor|>Just enable the "show usernames" boolean. Why does the function need that boolean? For feature compatibility with PHP 2.0 <|eor|><|soopr|>Jesus christ, you couldn't be more wrong! It's "real_show_usernames".<|eoopr|><|sor|>Which php.ini file do I have to enable it in? Or should I just do it at runtime?<|eor|><|sor|>I think that's a compile switch.<|eor|><|eoss|><|endoftext|>
6
lolphp
catcradle5
cdfwqa5
<|soss|><|sot|>[meta] Why does this subreddit have the css display: none; on usernames and dates?<|eot|><|sost|>It's really strange and I can't figure out why you'd do such a thing. It just obfuscates things, you can still just disable custom subreddit css or look at the html to get usernames. All it does is make it annoying.<|eost|><|sor|>You have to admit it fits well within the PHP philosophy, though...<|eor|><|sor|>Just enable the "show usernames" boolean. Why does the function need that boolean? For feature compatibility with PHP 2.0 <|eor|><|sor|>Boolean? Hah. No, you need to do `ini_set("show_comment_usernames_and_dates", "on")`. No true or false here. But be sure to include it at the top of every file because .htaccess defaults it to "off"! Though on some configurations this won't be the case and it'll be in php.ini instead of .htaccess. And there it may default to on or off. So be sure to check the default in both php.ini and .htaccess. Also in older versions the setting doesn't exist, in which case you can set it with the superglobal `$HTTP_DONT_HIDE_COMMENT_USERNAMES_AND_DATES` but this is deprecated in versions that are still too old to have the ini setting but new enough to use one of the standard superglobal arrays, in which case you can then just use `$_SESSION['DONT_HIDE_COMMENT_USERNAMES_AND_DATES']`. Even though it's deprecated the old superglobal will still take effect and will actually take precedence over the session variable so be careful! And if the session doesn't exist yet you'll need to create a stub session for every user, even unregistered ones. Note that these are all deprecated in PHP 5.7 though, in which case you'll need to use `show_usernames_and_dates()`. But this may not work as expected because it acts as a NO-OP if the value is already set in php.ini or apache.conf or apache2.conf (sometimes httpd.conf) or your `sites-enabled` vhost config file or .htaccess or a previous `ini_set()`, despite all those being deprecated for the setting, so you'll need to use `show_usernames_and_dates(true)`, "true" of course meaning "force" in this case. Though unfortunately someone found a security flaw in it the day it was shipped so now in 5.7.1 you must ALWAYS be sure to use `real_show_usernames_and_dates()`. The API changed though so if you pass `real_show_usernames_and_dates(true)` it will actually show only the usernames, NOT the dates, as the signature is now `real_show_usernames_and_dates($onlyUsernames, $force)` so for the old behavior you'll have to use `real_show_usernames_and_dates(false, true)`. Also, to simplify usage (having both "on" and "off" as settings in the past were of course confusing for many beginners): once you call it, there is no way to reverse it. Well you can, because the function call actually just sets a name-mangled session variable, so you could change the value of that variable or just destroy and recreate the session, but we don't recommend this. But someone in the documentation comments will probably give you a code snippet you can use to do this. And this is all in the documentation, so you're a blithering idiot if you think this is confusing behavior.<|eor|><|soopr|>...You get some gold.<|eoopr|><|sor|>Thank you!<|eor|><|eoss|><|endoftext|>
5
lolphp
kingguru
136k7j
<|sols|><|sot|>php_uname returns a description of the OS PHP is running on or the OS PHP was built on.<|eot|><|sol|>http://php.net/manual/en/function.php-uname.php<|eol|><|eols|><|endoftext|>
33
lolphp
DevestatingAttack
c71cyd6
<|sols|><|sot|>php_uname returns a description of the OS PHP is running on or the OS PHP was built on.<|eot|><|sol|>http://php.net/manual/en/function.php-uname.php<|eol|><|sor|>God fucking dammit why. Why is the acceptable behavior to just deliver an unexpected and WRONG answer instead of straight up failing and saying "uname not found on your platform"? Why is it acceptable to treat every single error as an opportunity to give wrong answers instead of right answers?<|eor|><|eols|><|endoftext|>
38
lolphp
kingguru
c718qq3
<|sols|><|sot|>php_uname returns a description of the OS PHP is running on or the OS PHP was built on.<|eot|><|sol|>http://php.net/manual/en/function.php-uname.php<|eol|><|sor|>Nothing new, but still amazing.<|eor|><|soopr|>I realize it's not new, just didn't see it posted to /r/lolphp before. The reason I found out about it was because I for the first time in a long time had to look up something on php.net for other reasons than a good laugh. Unsurprisingly, I ended up with a good laugh instead. :-)<|eoopr|><|eols|><|endoftext|>
8
lolphp
kingguru
c71r1u8
<|sols|><|sot|>php_uname returns a description of the OS PHP is running on or the OS PHP was built on.<|eot|><|sol|>http://php.net/manual/en/function.php-uname.php<|eol|><|sor|>> This will only happen if your uname() library call either doesn't exist or doesn't work. I'm curious which distros this would happen on. Are we talking RHEL 1.0 or something?<|eor|><|sor|>According to the [uname(2) man page](http://www.kernel.org/doc/man-pages/online/pages/man2/uname.2.html): > CONFORMING TO > SVr4, POSIX.1-2001. There is no uname() call in 4.3BSD. SVR4 was a System V spec released in 1988. 4.3BSD was released in 1986. It looks as if this comes up if you're running on an OS the predates the late 1980's. RHEL 1.0 was 1994. Linux itself was released in late 1991. So... This behaviour will come up if you're running a copy of BSD or another Unix from ~1985. But if you're running software on an operating system over a quarter century its senior, you have to expect some seriously weird behaviour.<|eor|><|soopr|>I think it is very safe to assume that this function will not fail, but the WTF is that there's no way to be sure if it fails since the result returned will still look valid. I cannot imagine how anyone in their right mind would implement this kind of behavior.<|eoopr|><|sor|>[deleted]<|eor|><|sor|>`uname` is a system call, not just a utility. And PHP is definitely not shelling out to get uname info.<|eor|><|sor|>How definite are we talking? "There's no good reason whatsoever to do that, and nobody in their right minds would do that" definite, or "I checked the source and it's not there" definite?<|eor|><|soopr|>> "There's no good reason whatsoever to do that, and nobody in their right minds would do that" definite Which is not really that definite considering the subject we're discussing. :-) Anyway, the function is defined [here](http://svn.php.net/viewvc/php/php-src/trunk/ext/standard/info.c?revision=324289&view=markup) and does indeed use the system call. Looking at the code, I also found a workaround for the broken behavior. If the call to uname fails or is compiled on a platform where the system call isn't defined, the function always returns whatever PHP_UNAME is defined to no matter which argument it was called with. That is of course a big WTF in itself, but that means that you could call the function with different arguments and if it returns the same value each time, the function call has failed. I don't know why I'm spending so much time looking into this, I should really have better things to do with my life. :-)<|eoopr|><|eols|><|endoftext|>
7
lolphp
kingguru
c71pob6
<|sols|><|sot|>php_uname returns a description of the OS PHP is running on or the OS PHP was built on.<|eot|><|sol|>http://php.net/manual/en/function.php-uname.php<|eol|><|sor|>God fucking dammit why. Why is the acceptable behavior to just deliver an unexpected and WRONG answer instead of straight up failing and saying "uname not found on your platform"? Why is it acceptable to treat every single error as an opportunity to give wrong answers instead of right answers?<|eor|><|soopr|>What is even more "impressive" IMO is that it most have taken an extra effort to implement this behavior. I would imagine it would have been easier to just return null and issue a warning level notice or one of the many other strange ways PHP deals with errors. Instead, the developers have gone out of their way to find some kind of not-valid-but-valid-looking result to return instead. I have tried to think of reason of why it was implemented this way. The only idea I could come up with was that it was originally implemented in the sane way were the function returned null. Then somewhere some PHP application depended on this function to always return a valid string, but this call failed for some reason (maybe it doesn't work on Windows?). Instead of fixing that, the PHP developers decided to "fix" this function instead. I know it sounds far fetched, but I cannot come up with a better explanation that doesn't involve the use of very strong medication. :-) <|eoopr|><|eols|><|endoftext|>
6
lolphp
ThisIsADogHello
c71nv1m
<|sols|><|sot|>php_uname returns a description of the OS PHP is running on or the OS PHP was built on.<|eot|><|sol|>http://php.net/manual/en/function.php-uname.php<|eol|><|sor|>> This will only happen if your uname() library call either doesn't exist or doesn't work. I'm curious which distros this would happen on. Are we talking RHEL 1.0 or something?<|eor|><|sor|>According to the [uname(2) man page](http://www.kernel.org/doc/man-pages/online/pages/man2/uname.2.html): > CONFORMING TO > SVr4, POSIX.1-2001. There is no uname() call in 4.3BSD. SVR4 was a System V spec released in 1988. 4.3BSD was released in 1986. It looks as if this comes up if you're running on an OS the predates the late 1980's. RHEL 1.0 was 1994. Linux itself was released in late 1991. So... This behaviour will come up if you're running a copy of BSD or another Unix from ~1985. But if you're running software on an operating system over a quarter century its senior, you have to expect some seriously weird behaviour.<|eor|><|soopr|>I think it is very safe to assume that this function will not fail, but the WTF is that there's no way to be sure if it fails since the result returned will still look valid. I cannot imagine how anyone in their right mind would implement this kind of behavior.<|eoopr|><|sor|>[deleted]<|eor|><|sor|>`uname` is a system call, not just a utility. And PHP is definitely not shelling out to get uname info.<|eor|><|sor|>How definite are we talking? "There's no good reason whatsoever to do that, and nobody in their right minds would do that" definite, or "I checked the source and it's not there" definite?<|eor|><|eols|><|endoftext|>
6
lolphp
rafaelschp
c718osq
<|sols|><|sot|>php_uname returns a description of the OS PHP is running on or the OS PHP was built on.<|eot|><|sol|>http://php.net/manual/en/function.php-uname.php<|eol|><|sor|>Serious question, why would you want to know what OS your copy of PHP was compiled on?<|eor|><|sor|>Maybe to test for specific bugs in that platform? Also, if you use PHP on android (Is that possible?) it will have to be cross-copiled from other OS. It can change behauvior depending on where it came from.<|eor|><|eols|><|endoftext|>
5
lolphp
kingguru
c71c7y8
<|sols|><|sot|>php_uname returns a description of the OS PHP is running on or the OS PHP was built on.<|eot|><|sol|>http://php.net/manual/en/function.php-uname.php<|eol|><|sor|>> This will only happen if your uname() library call either doesn't exist or doesn't work. I'm curious which distros this would happen on. Are we talking RHEL 1.0 or something?<|eor|><|sor|>According to the [uname(2) man page](http://www.kernel.org/doc/man-pages/online/pages/man2/uname.2.html): > CONFORMING TO > SVr4, POSIX.1-2001. There is no uname() call in 4.3BSD. SVR4 was a System V spec released in 1988. 4.3BSD was released in 1986. It looks as if this comes up if you're running on an OS the predates the late 1980's. RHEL 1.0 was 1994. Linux itself was released in late 1991. So... This behaviour will come up if you're running a copy of BSD or another Unix from ~1985. But if you're running software on an operating system over a quarter century its senior, you have to expect some seriously weird behaviour.<|eor|><|soopr|>I think it is very safe to assume that this function will not fail, but the WTF is that there's no way to be sure if it fails since the result returned will still look valid. I cannot imagine how anyone in their right mind would implement this kind of behavior.<|eoopr|><|eols|><|endoftext|>
5
lolphp
kingguru
11niu5
<|sols|><|sot|>PHP Annotations Are a Horrible Idea<|eot|><|sol|>http://theunraveler.com/blog/2012/php-annotations-are-a-horrible-idea/<|eol|><|eols|><|endoftext|>
29
lolphp
vytah
c6o6hcp
<|sols|><|sot|>PHP Annotations Are a Horrible Idea<|eot|><|sol|>http://theunraveler.com/blog/2012/php-annotations-are-a-horrible-idea/<|eol|><|sor|>PHP: stealing mediocre ideas from Java and making them worse since 2004. <|eor|><|eols|><|endoftext|>
19
lolphp
Andryu67
c6o5vjv
<|sols|><|sot|>PHP Annotations Are a Horrible Idea<|eot|><|sol|>http://theunraveler.com/blog/2012/php-annotations-are-a-horrible-idea/<|eol|><|sor|>I like how my gut told me it sounded odd when I saw it in /r/PHP only to have it reassured this way in my front page: [http://i.imgur.com/dPTAT.png](http://i.imgur.com/dPTAT.png)<|eor|><|eols|><|endoftext|>
8
lolphp
kingguru
c6o8a6h
<|sols|><|sot|>PHP Annotations Are a Horrible Idea<|eot|><|sol|>http://theunraveler.com/blog/2012/php-annotations-are-a-horrible-idea/<|eol|><|sor|>Why is this in /r/lolphp? Are you saying that comment-based annotations are a swell idea, that the alternatives he's proposing are retarded or are you just making fun of PHP's lack of proper annotations? I dun get it.<|eor|><|soopr|>I didn't write the linked article, but I found the whole idea of making comments in code affect the functionality of the code to be a very horrible idea and this was the article I stumbled upon. As infinull has pointed out, this is not really a problem with PHP but I think it could be said that it might be related to the thinking (or lack of) in the PHP community. Sorry if this is not worthy of a post to /r/lolphp, but on the other hand this subreddit doesn't exactly get flooded with posts, so I hope we'll all survive a post that might be slightly off topic. :-)<|eoopr|><|eols|><|endoftext|>
5
lolphp
ealf
udeml
<|sols|><|sot|>The textbook implementation of edit distance takes O(n) work. The PHP standard library can compute a greedy approximation in (n).<|eot|><|sol|>http://www.php.net/similar_text<|eol|><|eols|><|endoftext|>
30
lolphp
toomuchvitriol
c4ugmen
<|sols|><|sot|>The textbook implementation of edit distance takes O(n) work. The PHP standard library can compute a greedy approximation in (n).<|eot|><|sol|>http://www.php.net/similar_text<|eol|><|sor|>I can only assume the source is cited as `Oliver [1993]` because that's how they've seen other people cite things, completely failing to understand that it's supposed to be a reference to the full citation at the end of the paper. Some poor soul on StackOverflow managed to find the book. From the blurb: "Less mathematical and more practical in approach than other volumes, it helps programmers save research and programming time and enables them to quickly and easily generate efficient structured code in solving such problems." They cited a *copybook*.<|eor|><|eols|><|endoftext|>
14
lolphp
ealf
c4untwx
<|sols|><|sot|>The textbook implementation of edit distance takes O(n) work. The PHP standard library can compute a greedy approximation in (n).<|eot|><|sol|>http://www.php.net/similar_text<|eol|><|sor|>Extra WTF: they also have a pretty generic edit distance function called [`levenshtein`](http://nl.php.net/manual/en/function.levenshtein.php) which is indeed O(mn).<|eor|><|soopr|>Oh dear God, is there any part of this language that does NOT have another WTF hidden inside it?! First of all, it works on bytes, so you can only use it for ASCII. Even then, it silently fails if your input string is longer than 256 bytes, and returns... Minus one. Not infinity. Not NaN. Not an exception. Minus one. This, uhm, *slightly* important fact is only mentioned in the "RETURN VALUE" section of the "best documentation on the web". Bonus WTF: /* {{{ custom_levdist */ static int custom_levdist(char *str1, char *str2, char *callback_name TSRMLS_DC) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The general Levenshtein support is not there yet"); /* not there yet */ return -1; } /* }}} */ <|eoopr|><|eols|><|endoftext|>
9
lolphp
ealf
c4uuuny
<|sols|><|sot|>The textbook implementation of edit distance takes O(n) work. The PHP standard library can compute a greedy approximation in (n).<|eot|><|sol|>http://www.php.net/similar_text<|eol|><|sor|>Extra WTF: they also have a pretty generic edit distance function called [`levenshtein`](http://nl.php.net/manual/en/function.levenshtein.php) which is indeed O(mn).<|eor|><|soopr|>Oh dear God, is there any part of this language that does NOT have another WTF hidden inside it?! First of all, it works on bytes, so you can only use it for ASCII. Even then, it silently fails if your input string is longer than 256 bytes, and returns... Minus one. Not infinity. Not NaN. Not an exception. Minus one. This, uhm, *slightly* important fact is only mentioned in the "RETURN VALUE" section of the "best documentation on the web". Bonus WTF: /* {{{ custom_levdist */ static int custom_levdist(char *str1, char *str2, char *callback_name TSRMLS_DC) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The general Levenshtein support is not there yet"); /* not there yet */ return -1; } /* }}} */ <|eoopr|><|soopr|>Ooh, I missed this part of the documentation: > A second variant will take three additional parameters that define the cost of insert, replace and delete operations. This is more general and adaptive than variant one, but not as efficient. Guess which version is actually implemented by calling which version with the fixed parameters `1, 1, 1`...<|eoopr|><|eols|><|endoftext|>
5
lolphp
ManchegoObfuscator
qdxz9
<|sols|><|sot|>If I'm half as drunk as this PHP error message I'm definitively having a great time<|eot|><|sol|>https://twitter.com/#!/ircmaxell/status/175070904659886080<|eol|><|eols|><|endoftext|>
34
lolphp
tweet_poster
c3wtein
<|sols|><|sot|>If I'm half as drunk as this PHP error message I'm definitively having a great time<|eot|><|sol|>https://twitter.com/#!/ircmaxell/status/175070904659886080<|eol|><|sor|>***ircmaxell***: >&#91;2012/03/01&#93;&#91;04:12:10&#93; >[&#91;Translate&#93;](http://translate.google.com/#auto|auto|You know it%27s never a good thing to see this error: %22PHP Warning: Interface Traversable cannot contain non abstract method }Bn%28%29 in Unknown%22 'google translate this tweet'): You know it's never a good thing to see this error: "PHP Warning: Interface Traversable cannot contain non abstract method }Bn&#40;&#41; in Unknown" [&#91;This comment was posted by a bot&#93;&#91;FAQ&#93;](http://www.reddit.com/r/tweet_poster/faq 'tweet_poster FAQ')[&#91;Did I get it wrong?&#93;](http://www.reddit.com/message/compose/?to=tweet_poster&subject=Error%20Report&message=[Oops!](http://reddit.com/r/lolphp/comments/qdxz9\)%0d%0dPlease leave the subject and this link unaltered, but feel free to add a description here. 'report an error')<|eor|><|eols|><|endoftext|>
10
lolphp
Takeoded
ni11yx
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|eols|><|endoftext|>
28
lolphp
Smooth-Zucchini4923
gz07jvh
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|soopr|>i imagine the code is something like ``` uint16_t i=0; do{ ++i; name="prefix"+bin2hex(pack ( 'v', i )); }while(file_exists(name) && i < 65535); ``` haven't actually checked though<|eoopr|><|sor|>I think I figured out what causes this limitation. tempnam() is defined in the PHP source code within ext/standard/file.c. That calls php_open_temporary_fd_ex() in main/php_open_temporary_file.c. That calls php_do_open_temporary_file(). On Windows, this uses the Windows API GetTempFileNameW() to create the file. The [documentation](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamew) of that API says this: > Only the lower 16 bits of the *uUnique* parameter are used. This limits **GetTempFileName** to a maximum of 65,535 unique file names if the *lpPathName* and *lpPrefixString* parameters remain the same. > > Due to the algorithm used to generate file names, *GetTempFileName* can perform poorly when creating a large number of files with the same prefix. In such cases, it is recommended that you construct unique file names based on **GUID**s. Now, let's say that fails. In php_open_temporary_fd_ex(), there's a fallback when creating a temporary file outside the default location: it will retry creating the temporary file in the default location, and issue an E_NOTICE. This limitation is caused by the implementation relying on GetTempFileNameW().<|eor|><|eols|><|endoftext|>
18
lolphp
emperorkrulos
gyzzk53
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|sor|>Had a run in with this on our CI-pipeline. I was running integration tests using guzzle. Guzzle streams the response to a tmpfile. The tmpfiles didn't get deleted for some reason. Suddenly the tests stop working, because curl couldn't create a temp resource. I wrote a script to check file permissions, see where the tmpfiles ended up at. Also created a tmpfile and a minimal curl invokation to reproduce the error. Permissions were correct, I could create a tmpfile, but my minimal curl invokation failed. That led me to believe that tmp wasn't the problem. Restarted the server several times to no avail. I suspected one of the juniors messed with the installation. I asked a colleague for help, just to verify my results, before I start to tear apart the system. He luckily opened the tmpfolder to have a look. We saw 100 K+ files. 65534 of which were named phpXXXX.tmp, where X were hex chars. So my tmpfile was created using a different namin pattern, than curl's tmpfile. They both used the same code.<|eor|><|eols|><|endoftext|>
14
lolphp
Smooth-Zucchini4923
gz16x0b
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|soopr|>i imagine the code is something like ``` uint16_t i=0; do{ ++i; name="prefix"+bin2hex(pack ( 'v', i )); }while(file_exists(name) && i < 65535); ``` haven't actually checked though<|eoopr|><|sor|>I think I figured out what causes this limitation. tempnam() is defined in the PHP source code within ext/standard/file.c. That calls php_open_temporary_fd_ex() in main/php_open_temporary_file.c. That calls php_do_open_temporary_file(). On Windows, this uses the Windows API GetTempFileNameW() to create the file. The [documentation](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamew) of that API says this: > Only the lower 16 bits of the *uUnique* parameter are used. This limits **GetTempFileName** to a maximum of 65,535 unique file names if the *lpPathName* and *lpPrefixString* parameters remain the same. > > Due to the algorithm used to generate file names, *GetTempFileName* can perform poorly when creating a large number of files with the same prefix. In such cases, it is recommended that you construct unique file names based on **GUID**s. Now, let's say that fails. In php_open_temporary_fd_ex(), there's a fallback when creating a temporary file outside the default location: it will retry creating the temporary file in the default location, and issue an E_NOTICE. This limitation is caused by the implementation relying on GetTempFileNameW().<|eor|><|soopr|>>there's a fallback when creating a temporary file outside the default location: it will retry creating the temporary file in the ~~default~~ *wrong* location, and issue an E\_NOTICE. ftfy \^\^<|eoopr|><|sor|>I mean, we can argue about the wisdom of this choice, but PHP's choice isn't unprecedented. It's not the first language to try a series of temporary directories and use the first one which works. The namesake of [tempnam](https://www.man7.org/linux/man-pages/man3/tempnam.3.html) tries directories in the following order: 1. $TMPDIR environment variable 2. The dir argument 3. The P_tmpdir value defined in stdio.h ("/tmp" in the version of glibc I looked at.) 4. "An implementation defined value" (Yes, you read that correctly. In the C version of tempnam, if $TMPDIR is set, it takes precedence *over the argument you supply*.) Arguably, PHP's order makes more sense, because it makes the programmer-supplied argument take precedence over system-wide configuration. Although PHP's order makes more sense, I agree that the concept of doing the fallback is a bad idea. If the user specifies a directory for the temporary file to land in, they probably had a good reason to put it in that directory.<|eor|><|eols|><|endoftext|>
11
lolphp
Regimardyl
gyzijto
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|soopr|>i imagine the code is something like ``` uint16_t i=0; do{ ++i; name="prefix"+bin2hex(pack ( 'v', i )); }while(file_exists(name) && i < 65535); ``` haven't actually checked though<|eoopr|><|sor|>[Fixed formatting.](https://np.reddit.com/r/backtickbot/comments/ni16to/httpsnpredditcomrlolphpcommentsni11yxon_ntfs_this/) Hello, Takeoded: code blocks using triple backticks (\`\`\`) don't work on all versions of Reddit! Some users see [this](https://stalas.alm.lt/backformat/gyz9z9i.png) / [this](https://stalas.alm.lt/backformat/gyz9z9i.html) instead. To fix this, **indent every line with 4 spaces** instead. [FAQ](https://www.reddit.com/r/backtickbot/wiki/index) ^(You can opt out by replying with backtickopt6 to this comment.)<|eor|><|soopr|>why don't you let the reddit devs know? so maybe they can fix it?<|eoopr|><|sor|>Because reddit tries to slowly kill old reddit by adding new features (like e.g. triple backtick code blocks coming from commonmark) only to the new reddit.<|eor|><|eols|><|endoftext|>
11
lolphp
Smooth-Zucchini4923
gz064sf
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|soopr|>i imagine the code is something like ``` uint16_t i=0; do{ ++i; name="prefix"+bin2hex(pack ( 'v', i )); }while(file_exists(name) && i < 65535); ``` haven't actually checked though<|eoopr|><|sor|>[Fixed formatting.](https://np.reddit.com/r/backtickbot/comments/ni16to/httpsnpredditcomrlolphpcommentsni11yxon_ntfs_this/) Hello, Takeoded: code blocks using triple backticks (\`\`\`) don't work on all versions of Reddit! Some users see [this](https://stalas.alm.lt/backformat/gyz9z9i.png) / [this](https://stalas.alm.lt/backformat/gyz9z9i.html) instead. To fix this, **indent every line with 4 spaces** instead. [FAQ](https://www.reddit.com/r/backtickbot/wiki/index) ^(You can opt out by replying with backtickopt6 to this comment.)<|eor|><|soopr|>why don't you let the reddit devs know? so maybe they can fix it?<|eoopr|><|sor|>Trust me, they know. This issue has been here since day one of new reddit. I browse reddit in old reddit, because it looks better and is easier to use.<|eor|><|eols|><|endoftext|>
10
lolphp
Takeoded
gyz9z9i
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|soopr|>i imagine the code is something like ``` uint16_t i=0; do{ ++i; name="prefix"+bin2hex(pack ( 'v', i )); }while(file_exists(name) && i < 65535); ``` haven't actually checked though<|eoopr|><|eols|><|endoftext|>
7
lolphp
Takeoded
gz12wql
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|soopr|>i imagine the code is something like ``` uint16_t i=0; do{ ++i; name="prefix"+bin2hex(pack ( 'v', i )); }while(file_exists(name) && i < 65535); ``` haven't actually checked though<|eoopr|><|sor|>I think I figured out what causes this limitation. tempnam() is defined in the PHP source code within ext/standard/file.c. That calls php_open_temporary_fd_ex() in main/php_open_temporary_file.c. That calls php_do_open_temporary_file(). On Windows, this uses the Windows API GetTempFileNameW() to create the file. The [documentation](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamew) of that API says this: > Only the lower 16 bits of the *uUnique* parameter are used. This limits **GetTempFileName** to a maximum of 65,535 unique file names if the *lpPathName* and *lpPrefixString* parameters remain the same. > > Due to the algorithm used to generate file names, *GetTempFileName* can perform poorly when creating a large number of files with the same prefix. In such cases, it is recommended that you construct unique file names based on **GUID**s. Now, let's say that fails. In php_open_temporary_fd_ex(), there's a fallback when creating a temporary file outside the default location: it will retry creating the temporary file in the default location, and issue an E_NOTICE. This limitation is caused by the implementation relying on GetTempFileNameW().<|eor|><|soopr|>>there's a fallback when creating a temporary file outside the default location: it will retry creating the temporary file in the ~~default~~ *wrong* location, and issue an E\_NOTICE. ftfy \^\^<|eoopr|><|eols|><|endoftext|>
7
lolphp
AyrA_ch
gz1n9qr
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|soopr|>i imagine the code is something like ``` uint16_t i=0; do{ ++i; name="prefix"+bin2hex(pack ( 'v', i )); }while(file_exists(name) && i < 65535); ``` haven't actually checked though<|eoopr|><|sor|>It's weird that it only happens on NTFS. NTFS supports 2^32 files total, and there's no per-directory limit. It's possible though that the documentation is wrong and this is not an NTFS thing, but a Windows thing, because iirc FAT32 has a 2^16 files per-folder limit.<|eor|><|soopr|>> because iirc FAT32 has a 2^16 files per-folder limit dang just tested, you're right (actually it's (2**16)-3 , i have no idea where they got the -3 from), tested on kernel linux kernel 4.19.0<|eoopr|><|sor|>> i have no idea where they got the -3 from Every directory (except root) has two entries for "." and "..". The third entry is wasted as a terminator on the directory list. The root directory has no ".." but that entry is instead used as the drive label, and the reason why a FAT label is also restricted to 11 characters.<|eor|><|eols|><|endoftext|>
7
lolphp
iloveportalz0r
gz1gplk
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|soopr|>i imagine the code is something like ``` uint16_t i=0; do{ ++i; name="prefix"+bin2hex(pack ( 'v', i )); }while(file_exists(name) && i < 65535); ``` haven't actually checked though<|eoopr|><|sor|>[Fixed formatting.](https://np.reddit.com/r/backtickbot/comments/ni16to/httpsnpredditcomrlolphpcommentsni11yxon_ntfs_this/) Hello, Takeoded: code blocks using triple backticks (\`\`\`) don't work on all versions of Reddit! Some users see [this](https://stalas.alm.lt/backformat/gyz9z9i.png) / [this](https://stalas.alm.lt/backformat/gyz9z9i.html) instead. To fix this, **indent every line with 4 spaces** instead. [FAQ](https://www.reddit.com/r/backtickbot/wiki/index) ^(You can opt out by replying with backtickopt6 to this comment.)<|eor|><|soopr|>why don't you let the reddit devs know? so maybe they can fix it?<|eoopr|><|sor|>Because it's not a reddit issue. Old reddit supports markdown, but your code style is only supported in commonmark, which was created after reddit. New reddit however has commonmark.<|eor|><|soopr|>sounds like it would be trivial to backport a simple version of it though, just a simple regex ala replacing ``` /(?:^|\n)\`\`\`\n([\s\S]+?)\n\`\`\`(?:\n|$)/ ``` with <code>$1</code> would cover most usecases, i imagine<|eoopr|><|sor|>The problem is they don't care. It doesn't matter how easy it is to fix if they don't want to fix it.<|eor|><|eols|><|endoftext|>
7
lolphp
homeopathetic
gz2z0ln
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|sor|>If you have more than 65k files in one folder you're going to have bigger problems. If you need a solution that isn't limited to 65k it must be so hard to create one. Edit: people downvoting me clearly don't understand the performance cost of opening a folder to iterate it's subfolders when it has thousands of files inside. https://serverfault.com/questions/98235/how-many-files-in-a-directory-is-too-many-downloading-data-from-net After 1000 files NTFS and ext3 start to see performance issues, ext4 probably isn't perfect either Then there's NFS, good luck opening a folder with thousands of files over NFS. Tools like bigdir exist specifically to solve this https://github.com/glasswalk3r/Linux-NFS-BigDir<|eor|><|sor|>> If you have more than 65k files in one folder you're going to have bigger problems. What? Why? Here's two places I have folders with more than 65k files for completely mundane reasons: * A maildir with a large mailing list * A data directory with about 100k training files for a deep network Care to tell me why this is wrong or what my bigger problems are?<|eor|><|eols|><|endoftext|>
6
lolphp
Dr_Legacy
gz1lj9h
<|sols|><|sot|>On NTFS this also happens if the specified directory contains more than 65534 files.<|eot|><|sol|>https://www.php.net/manual/en/function.tempnam.php<|eol|><|soopr|>i imagine the code is something like ``` uint16_t i=0; do{ ++i; name="prefix"+bin2hex(pack ( 'v', i )); }while(file_exists(name) && i < 65535); ``` haven't actually checked though<|eoopr|><|sor|>It's weird that it only happens on NTFS. NTFS supports 2^32 files total, and there's no per-directory limit. It's possible though that the documentation is wrong and this is not an NTFS thing, but a Windows thing, because iirc FAT32 has a 2^16 files per-folder limit.<|eor|><|soopr|>> because iirc FAT32 has a 2^16 files per-folder limit dang just tested, you're right (actually it's (2**16)-3 , i have no idea where they got the -3 from), tested on kernel linux kernel 4.19.0<|eoopr|><|sor|>> i have no idea where they got the -3 from `.`, `..`, and the obligatory off-by-one<|eor|><|eols|><|endoftext|>
5
lolphp
zilltine
m67z3r
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|eoss|><|endoftext|>
31
lolphp
fragglet
gr4g1pf
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>not a LOL if you read documentation for scrict flag `in_array(0, ['IsThisLolPhp'], true);` [https://www.php.net/manual/en/function.in-array.php](https://www.php.net/manual/en/function.in-array.php)<|eor|><|sor|>Just because it's documented it doesn't automatically mean it's okay.<|eor|><|eoss|><|endoftext|>
54
lolphp
SAmaruVMR
gr46mzj
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>That's because of type juggling. For example, you're checking an integer with a string. What happens behind the courtains is that the php try to see if in the string that you're comparing the first character is actually a number. It isn't? Okay let's switch the string to 0, that's why 0 === 0 Another example if you try something like: 1 == '1asdjkgndasjgdasgh' or 6 == '6adgadgadg' These are all true. That's why you shouldn't use loose type comparison. They fixed this in php 8 but it's just habit to always use triple equals (strict type comparison)<|eor|><|eoss|><|endoftext|>
21
lolphp
CollieOxenfree
gr5ofjm
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>not a LOL if you read documentation for scrict flag `in_array(0, ['IsThisLolPhp'], true);` [https://www.php.net/manual/en/function.in-array.php](https://www.php.net/manual/en/function.in-array.php)<|eor|><|sor|>Just because it's documented it doesn't automatically mean it's okay.<|eor|><|sor|>I don't see the problem, [the issue is well documented](https://i.redd.it/wh1nymzkozd41.jpg)!<|eor|><|eoss|><|endoftext|>
19
lolphp
SAmaruVMR
gr480kf
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>[false](https://phpize.online/?phpses=78819a38111285235a0b1f73cc475ef3) This sub definitely needs a FAQ wiki<|eor|><|sor|>You're using PHP 8. They fixed just that. If you try any version below PHP 8 it will result in a true boolean result.<|eor|><|eoss|><|endoftext|>
13
lolphp
bkdotcom
gr4b0v6
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>That's because of type juggling. For example, you're checking an integer with a string. What happens behind the courtains is that the php try to see if in the string that you're comparing the first character is actually a number. It isn't? Okay let's switch the string to 0, that's why 0 === 0 Another example if you try something like: 1 == '1asdjkgndasjgdasgh' or 6 == '6adgadgadg' These are all true. That's why you shouldn't use loose type comparison. They fixed this in php 8 but it's just habit to always use triple equals (strict type comparison)<|eor|><|soopr|>Alright, that makes sense. You can actually pass 3rd parameter to in\_array method to use strict type comparison<|eoopr|><|sor|>> You can actually pass 3rd parameter to in_array method to use strict type comparison did you know that before you posted?<|eor|><|eoss|><|endoftext|>
13
lolphp
zilltine
gr4lrlc
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>That's because of type juggling. For example, you're checking an integer with a string. What happens behind the courtains is that the php try to see if in the string that you're comparing the first character is actually a number. It isn't? Okay let's switch the string to 0, that's why 0 === 0 Another example if you try something like: 1 == '1asdjkgndasjgdasgh' or 6 == '6adgadgadg' These are all true. That's why you shouldn't use loose type comparison. They fixed this in php 8 but it's just habit to always use triple equals (strict type comparison)<|eor|><|soopr|>Alright, that makes sense. You can actually pass 3rd parameter to in\_array method to use strict type comparison<|eoopr|><|sor|>> You can actually pass 3rd parameter to in_array method to use strict type comparison did you know that before you posted?<|eor|><|soopr|>No, i checked it after reading comment<|eoopr|><|eoss|><|endoftext|>
11
lolphp
LeadingArmadillo
gr4clxb
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>not a LOL if you read documentation for scrict flag `in_array(0, ['IsThisLolPhp'], true);` [https://www.php.net/manual/en/function.in-array.php](https://www.php.net/manual/en/function.in-array.php)<|eor|><|eoss|><|endoftext|>
9
lolphp
zilltine
gr4savg
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>[deleted]<|eor|><|soopr|>I did, i had to find if array key contains one of possible keys. Basically had to find keys recursively on undefined structure, it was finding first elements in unassoc array<|eoopr|><|eoss|><|endoftext|>
9
lolphp
zilltine
gr4723g
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>That's because of type juggling. For example, you're checking an integer with a string. What happens behind the courtains is that the php try to see if in the string that you're comparing the first character is actually a number. It isn't? Okay let's switch the string to 0, that's why 0 === 0 Another example if you try something like: 1 == '1asdjkgndasjgdasgh' or 6 == '6adgadgadg' These are all true. That's why you shouldn't use loose type comparison. They fixed this in php 8 but it's just habit to always use triple equals (strict type comparison)<|eor|><|soopr|>Alright, that makes sense. You can actually pass 3rd parameter to in\_array method to use strict type comparison<|eoopr|><|eoss|><|endoftext|>
7
lolphp
elcapitanoooo
gr5b76m
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>not a LOL if you read documentation for scrict flag `in_array(0, ['IsThisLolPhp'], true);` [https://www.php.net/manual/en/function.in-array.php](https://www.php.net/manual/en/function.in-array.php)<|eor|><|sor|>Bolted on params, the river flows west<|eor|><|eoss|><|endoftext|>
7
lolphp
colshrapnel
gr48v8q
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>[false](https://phpize.online/?phpses=78819a38111285235a0b1f73cc475ef3) This sub definitely needs a FAQ wiki<|eor|><|sor|>You're using PHP 8. They fixed just that. If you try any version below PHP 8 it will result in a true boolean result.<|eor|><|sor|>It was a subtle reminder that the OP is a bit late with their lol<|eor|><|eoss|><|endoftext|>
5
lolphp
fatboycreeper
gr4ivd3
<|soss|><|sot|>Is 0 in array<|eot|><|sost|>&#x200B; in_array(0, ['IsThisLolPhp']) Answer is true &#x200B;<|eost|><|sor|>[false](https://phpize.online/?phpses=78819a38111285235a0b1f73cc475ef3) This sub definitely needs a FAQ wiki<|eor|><|sor|>You're using PHP 8. They fixed just that. If you try any version below PHP 8 it will result in a true boolean result.<|eor|><|sor|>It was a subtle reminder that the OP is a bit late with their lol<|eor|><|sor|>lollegacyphp<|eor|><|eoss|><|endoftext|>
5
lolphp
CheezyXenomorph
a0o35o
<|sols|><|sot|>Arrow functions!<|eot|><|sol|>https://twitter.com/calebporzio/status/1067163387338080259?s=19<|eol|><|eols|><|endoftext|>
31
lolphp
ArtyomR
eajeoef
<|sols|><|sot|>Arrow functions!<|eot|><|sol|>https://twitter.com/calebporzio/status/1067163387338080259?s=19<|eol|><|sor|>The perfect programming language doesnt exi-<|eor|><|eols|><|endoftext|>
8
lolphp
CheezyXenomorph
eakc70m
<|sols|><|sot|>Arrow functions!<|eot|><|sol|>https://twitter.com/calebporzio/status/1067163387338080259?s=19<|eol|><|sor|>What the hell is wrong with that person's font preference.<|eor|><|soopr|>Yeah, I thought it was [Fira code](https://github.com/tonsky/FiraCode) at first which is the font I use for coding, as the coding ligatures are awesome, but that F is a freak.<|eoopr|><|eols|><|endoftext|>
5
lolphp
Takeoded
74fb4u
<|sols|><|sot|>Warning: SSL: The operation completed successfully.<|eot|><|sol|>https://stackoverflow.com/questions/46337963/php-soap-clients-http-headers-error<|eol|><|eols|><|endoftext|>
29