subreddit stringclasses 7
values | author stringlengths 3 20 | id stringlengths 5 7 | content stringlengths 67 30.4k | score int64 0 140k |
|---|---|---|---|---|
lolphp | Saltub | dlc7ut9 | <|sols|><|sot|>When is parse_url going to be deprecated ?<|eot|><|sol|>https://3v4l.org/ht82k<|eol|><|sor|>Instead of being so smug, why don't you report it as a bug?<|eor|><|sor|>I've reported you as a bug.<|eor|><|eols|><|endoftext|> | 21 |
lolphp | the_alias_of_andrea | dlcjpxt | <|sols|><|sot|>When is parse_url going to be deprecated ?<|eot|><|sol|>https://3v4l.org/ht82k<|eol|><|sor|>Seems to me somebody should've read [RFC 3986](https://tools.ietf.org/html/rfc3986) before haphazardly implementing something like that.
[Here's the PHP source](https://github.com/php/php-src/blob/513b0093c2b480bb752fb354012f42c446769486/ext/standard/url.c#L97-L321). If you ask me, 224 lines of C code seem *a little* on the low end to implement a parser for something that needs 10 chapters and 4 appendices to specify.<|eor|><|sor|>> 224 lines of C code seem a little on the low end to implement a parser for something that needs 10 chapters and 4 appendices to specify.
Having implemented an URL parser myself (admittedly a fairly primitive one), I can assure you that the specification takes up much more space than the code implementing it needs to. This isn't a useful metric.<|eor|><|eols|><|endoftext|> | 20 |
lolphp | minimim | dlc8tf3 | <|sols|><|sot|>When is parse_url going to be deprecated ?<|eot|><|sol|>https://3v4l.org/ht82k<|eol|><|sor|>Seems to me somebody should've read [RFC 3986](https://tools.ietf.org/html/rfc3986) before haphazardly implementing something like that.
[Here's the PHP source](https://github.com/php/php-src/blob/513b0093c2b480bb752fb354012f42c446769486/ext/standard/url.c#L97-L321). If you ask me, 224 lines of C code seem *a little* on the low end to implement a parser for something that needs 10 chapters and 4 appendices to specify.<|eor|><|soopr|>In defense of `parse_url` the function pre-date RFC3986 so the dev could not have guessed the rules that did not exist back then. Another reason to deprecate/replace the function with a more modern one/valid approach. <|eoopr|><|sor|>Do they also predate RFC 1738?
Was `parse_url` written before PHP itself?<|eor|><|eols|><|endoftext|> | 13 |
lolphp | nyamsprod | dldg4it | <|sols|><|sot|>When is parse_url going to be deprecated ?<|eot|><|sol|>https://3v4l.org/ht82k<|eol|><|sor|>It shouldn't be deprecated, its guts should be ripped out and rewritten.<|eor|><|soopr|>I believe some scripts out there sadly depends on its current guts form _
that's why we need`real_parse_url` or even better `SplURIObject` to keep the PHP spirit going\_()_/<|eoopr|><|eols|><|endoftext|> | 11 |
lolphp | nyamsprod | dlc2qdm | <|sols|><|sot|>When is parse_url going to be deprecated ?<|eot|><|sol|>https://3v4l.org/ht82k<|eol|><|sor|>Instead of being so smug, why don't you report it as a bug?<|eor|><|soopr|>Because I prefer to get this ASAP https://wiki.php.net/rfc/replace_parse_url I was hoping PHP7.2 would ship with it<|eoopr|><|eols|><|endoftext|> | 10 |
lolphp | mikeputerbaugh | dlhqm0v | <|sols|><|sot|>When is parse_url going to be deprecated ?<|eot|><|sol|>https://3v4l.org/ht82k<|eol|><|sor|>It shouldn't be deprecated, its guts should be ripped out and rewritten.<|eor|><|soopr|>I believe some scripts out there sadly depends on its current guts form _
that's why we need`real_parse_url` or even better `SplURIObject` to keep the PHP spirit going\_()_/<|eoopr|><|sor|>`parse_url($string, PARSEURL_MODE_REAL)`<|eor|><|eols|><|endoftext|> | 8 |
lolphp | MMauro94 | 6k0p40 | <|sols|><|sot|>array_diff breaks Exception catching when passing two arrays containing an item that can't be cast to string<|eot|><|sol|>https://3v4l.org/BaUji<|eol|><|eols|><|endoftext|> | 38 |
lolphp | the_alias_of_andrea | djil8x0 | <|sols|><|sot|>array_diff breaks Exception catching when passing two arrays containing an item that can't be cast to string<|eot|><|sol|>https://3v4l.org/BaUji<|eol|><|sor|>The handling of Exceptions and Errors (Throwables) with internal functions is a bit of a tricky issue, because basically we can't just unwind the C stack to handle them, so they only get handled if we include some kind of check for them. Thus this kind of issue.
There's no easy solution, unfortunately. If PHP was written in C++, maybe it could use its exception handling, but that'd be its own kettle of fish.<|eor|><|eols|><|endoftext|> | 18 |
lolphp | masklinn | djv2bxb | <|sols|><|sot|>array_diff breaks Exception catching when passing two arrays containing an item that can't be cast to string<|eot|><|sol|>https://3v4l.org/BaUji<|eol|><|sor|>The handling of Exceptions and Errors (Throwables) with internal functions is a bit of a tricky issue, because basically we can't just unwind the C stack to handle them, so they only get handled if we include some kind of check for them. Thus this kind of issue.
There's no easy solution, unfortunately. If PHP was written in C++, maybe it could use its exception handling, but that'd be its own kettle of fish.<|eor|><|sor|>> they only get handled if we include some kind of check for them. Thus this kind of issue.
Maybe if the API made sense that would happen *normally* rather than exceptionally?
MRI or CPython are also written in C, and they properly propagate exceptions through native code.<|eor|><|sor|>> Maybe if the API made sense that would happen normally rather than exceptionally?
The API isn't the problem, C is. C doesn't have exception handling.<|eor|><|sor|>Once again no, I'll bold it since you apparently managed to miss:
# MRI and CPython are both written in C and have no problem propagating exceptions<|eor|><|eols|><|endoftext|> | 9 |
lolphp | Various_Pickles | djqs3vi | <|sols|><|sot|>array_diff breaks Exception catching when passing two arrays containing an item that can't be cast to string<|eot|><|sol|>https://3v4l.org/BaUji<|eol|><|sor|>Exception handling in PHP is dependent on rolling a 15+ for initiative at the start of the encounter with the roving band of 2d4 manscorpions.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | DoctorWaluigiTime | djjw3bk | <|sols|><|sot|>array_diff breaks Exception catching when passing two arrays containing an item that can't be cast to string<|eot|><|sol|>https://3v4l.org/BaUji<|eol|><|sor|>The handling of Exceptions and Errors (Throwables) with internal functions is a bit of a tricky issue, because basically we can't just unwind the C stack to handle them, so they only get handled if we include some kind of check for them. Thus this kind of issue.
There's no easy solution, unfortunately. If PHP was written in C++, maybe it could use its exception handling, but that'd be its own kettle of fish.<|eor|><|sor|>> a bit of a tricky issue
That's putting it pretty fucking mildly.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Rican7 | 4becxk | <|sols|><|sot|>PHP doesn't understand daylight savings<|eot|><|sol|>https://3v4l.org/iTeSL<|eol|><|eols|><|endoftext|> | 36 |
lolphp | andsens | d18dnq6 | <|sols|><|sot|>PHP doesn't understand daylight savings<|eot|><|sol|>https://3v4l.org/iTeSL<|eol|><|sor|>Dear lord, that's horrible. Don't tell me they made their own [zoneinfo](https://en.wikipedia.org/wiki/Tz_database)?<|eor|><|eols|><|endoftext|> | 20 |
lolphp | treenaks | d18u9t0 | <|sols|><|sot|>PHP doesn't understand daylight savings<|eot|><|sol|>https://3v4l.org/iTeSL<|eol|><|sor|>Dear lord, that's horrible. Don't tell me they made their own [zoneinfo](https://en.wikipedia.org/wiki/Tz_database)?<|eor|><|sor|>[Don't make your own zoneinfo](https://www.youtube.com/watch?v=-5wpm-gesOY)<|eor|><|eols|><|endoftext|> | 16 |
lolphp | treenaks | d18wnve | <|sols|><|sot|>PHP doesn't understand daylight savings<|eot|><|sol|>https://3v4l.org/iTeSL<|eol|><|sor|>Dear lord, that's horrible. Don't tell me they made their own [zoneinfo](https://en.wikipedia.org/wiki/Tz_database)?<|eor|><|sor|>[Don't make your own zoneinfo](https://www.youtube.com/watch?v=-5wpm-gesOY)<|eor|><|sor|>Haha brilliant! He forgot [Paris](https://www.timeanddate.com/time/change/france/paris?year=1911) in 1911 though, 9 minutes 21 seconds difference, yay! :-)<|eor|><|sor|>The Netherlands, before the second world war, had a nice time zone too: https://en.wikipedia.org/wiki/UTC%2B00:20
> The exact timezone was GMT +0h 19m 32.13s until March 17, 1937, when it was simplified to GMT +0h 20m. When Germany occupied the Netherlands in World War II, Berlin Time was adopted, and this has been retained ever since.
<|eor|><|eols|><|endoftext|> | 13 |
lolphp | andsens | d18wi7w | <|sols|><|sot|>PHP doesn't understand daylight savings<|eot|><|sol|>https://3v4l.org/iTeSL<|eol|><|sor|>Dear lord, that's horrible. Don't tell me they made their own [zoneinfo](https://en.wikipedia.org/wiki/Tz_database)?<|eor|><|sor|>[Don't make your own zoneinfo](https://www.youtube.com/watch?v=-5wpm-gesOY)<|eor|><|sor|>Haha brilliant! He forgot [Paris](https://www.timeanddate.com/time/change/france/paris?year=1911) in 1911 though, 9 minutes 21 seconds difference, yay! :-)<|eor|><|eols|><|endoftext|> | 7 |
lolphp | the_alias_of_andrea | d18wqza | <|sols|><|sot|>PHP doesn't understand daylight savings<|eot|><|sol|>https://3v4l.org/iTeSL<|eol|><|sor|>Weird. I wonder if EST and EDT are aliased because they're often confused.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | gibranois | 3xkhvk | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|eols|><|endoftext|> | 40 |
lolphp | aaarrrggh | cy5fhux | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>It's kinda a fair point though. Php has improved a lot over the years, as have the practises employed by much of the community. His comment is pretty fair tbh.<|eor|><|eols|><|endoftext|> | 72 |
lolphp | Schmittfried | cy5j9t4 | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>It's kinda a fair point though. Php has improved a lot over the years, as have the practises employed by much of the community. His comment is pretty fair tbh.<|eor|><|sor|>It's not fair to call every critic of PHP an idiot. They've still not improved the ridiculous type coercion rules (and no, I'm not talking about weak typing in general; JS has weak typing, too, and I can live with it).<|eor|><|eols|><|endoftext|> | 35 |
lolphp | myhf | cy5ff1a | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>Wow he wrote Go and RoR. My brains are melting out.<|eor|><|eols|><|endoftext|> | 33 |
lolphp | the_alias_of_andrea | cy5k01a | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>Wow he wrote Go and RoR. My brains are melting out.<|eor|><|sor|>By that I think he means he wrote *in* them. His point is that he's written in other languages, he's not using PHP because it's the only thing he knows.<|eor|><|eols|><|endoftext|> | 25 |
lolphp | the_alias_of_andrea | cy5jw0g | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>People want to see things that confirm their biases. <|eor|><|sor|>PHP has a problem with this. Instead of reacting to statements that PHP sucks with acknowledgement that it sucks but saying it's nonetheless useful and getting somewhat better, instead people usually say that it doesn't suck anymore since <arbitrary event 2-4 years ago>.
Although in fairness I suppose it depends what you think sucks means, ehh<|eor|><|eols|><|endoftext|> | 23 |
lolphp | AlGoreBestGore | cy5q7yh | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>> I'm really excited for ~2018-2022 or so when we shit on the node.js community.
lol<|eor|><|eols|><|endoftext|> | 21 |
lolphp | Synes_Godt_Om | cy5s3qn | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>Same kind of cycle as Microsoft's had with their products
1. THIS PRODUCT IS PERFECT YOU'RE JUST AN IDIOT
1. THE LAST VERSION WAS AWFUL DON'T USE IT
1. GOTO 1<|eor|><|sor|>> Same kind of cycle as Microsoft's had with their products
No, not really. More like: "yes it sucks in various ways, but the overwhelming majority of criticism is essentially about php pre-5.3 and is therefore totally irrelevant and consequently these critics *are* idiots".
There is a reason why /r/lolphp has almost dried out.<|eor|><|eols|><|endoftext|> | 20 |
lolphp | BilgeXA | cy5j2au | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>Phil Sturgeon is a schmuck who genuinely believes he is a legend among men, and sadly, things like this only serve to fuel that ego.<|eor|><|eols|><|endoftext|> | 19 |
lolphp | the_alias_of_andrea | cy5jz3b | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>It's kinda a fair point though. Php has improved a lot over the years, as have the practises employed by much of the community. His comment is pretty fair tbh.<|eor|><|sor|>It's not fair to call every critic of PHP an idiot. They've still not improved the ridiculous type coercion rules (and no, I'm not talking about weak typing in general; JS has weak typing, too, and I can live with it).<|eor|><|sor|>The type coercion rules are improving little-by-little. Hexadecimal isn't supported in numeric strings now (removing a big inconsistency). Floats outside the range of an integer won't convert without throwing an error. At least for userland functions, null isn't accepted for everything.
Give it time. We can't "fix" everything overnight. It can never be fully consistent and sensible aside from removing type coercion entirely, and we can't simply break everything tomorrow anyway, because backwards-compatibility matters. But it's improving.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | the_alias_of_andrea | cy5odxc | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>It's kinda a fair point though. Php has improved a lot over the years, as have the practises employed by much of the community. His comment is pretty fair tbh.<|eor|><|sor|>It's not fair to call every critic of PHP an idiot. They've still not improved the ridiculous type coercion rules (and no, I'm not talking about weak typing in general; JS has weak typing, too, and I can live with it).<|eor|><|sor|>Anyone who has legitimate criticism against modern PHP will also be able to provide similar criticism for other languages. Unfortunately, people on the internet will get super defensive about any type of criticism against a language they use and make it into an "us vs them" problem.<|eor|><|sor|>PHP has some... unique quirks, though.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | smog_alado | cy5hg51 | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>tbh, Go and RoR are also silly in their own way.<|eor|><|eols|><|endoftext|> | 16 |
lolphp | polish_niceguy | cy61zxv | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>It's kinda a fair point though. Php has improved a lot over the years, as have the practises employed by much of the community. His comment is pretty fair tbh.<|eor|><|sor|>It's not fair to call every critic of PHP an idiot. They've still not improved the ridiculous type coercion rules (and no, I'm not talking about weak typing in general; JS has weak typing, too, and I can live with it).<|eor|><|sor|>Anyone who has legitimate criticism against modern PHP will also be able to provide similar criticism for other languages. Unfortunately, people on the internet will get super defensive about any type of criticism against a language they use and make it into an "us vs them" problem.<|eor|><|sor|>Still, only PHP provides enough content to constantly fuel a dedicated mocking subreddit.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | Vakieh | cy5ywy9 | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>Same kind of cycle as Microsoft's had with their products
1. THIS PRODUCT IS PERFECT YOU'RE JUST AN IDIOT
1. THE LAST VERSION WAS AWFUL DON'T USE IT
1. GOTO 1<|eor|><|sor|>That illustrates the fundamental Microsoft consumer mantra - you always always always skip a Microsoft release.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | dagbrown | cy62xz5 | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>It's kinda a fair point though. Php has improved a lot over the years, as have the practises employed by much of the community. His comment is pretty fair tbh.<|eor|><|sor|>It's not fair to call every critic of PHP an idiot. They've still not improved the ridiculous type coercion rules (and no, I'm not talking about weak typing in general; JS has weak typing, too, and I can live with it).<|eor|><|sor|>The type coercion rules are improving little-by-little. Hexadecimal isn't supported in numeric strings now (removing a big inconsistency). Floats outside the range of an integer won't convert without throwing an error. At least for userland functions, null isn't accepted for everything.
Give it time. We can't "fix" everything overnight. It can never be fully consistent and sensible aside from removing type coercion entirely, and we can't simply break everything tomorrow anyway, because backwards-compatibility matters. But it's improving.<|eor|><|sor|>> Hexadecimal isn't supported in numeric strings now
Oh good.
Now try this with PHP 7.0:
$foo = "0d9";
print "$foo\n";
$foo++;
print "$foo\n";
$foo++;
print "$foo\n";
Thank God that vital functionality has been left alone!<|eor|><|eols|><|endoftext|> | 14 |
lolphp | the_alias_of_andrea | cy5k11c | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>Phil Sturgeon is a schmuck who genuinely believes he is a legend among men, and sadly, things like this only serve to fuel that ego.<|eor|><|sor|>If you actually listen to half the things he says, he's not all that bad. A little arrogant, sure, but programmers seem to be prone to that.
I'm never really sure why there's this group of people that seem to hate him.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | philsturgeon | cy63dgr | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>Phil Sturgeon is a schmuck who genuinely believes he is a legend among men, and sadly, things like this only serve to fuel that ego.<|eor|><|sor|>He is a doucue bag brogrammer. Constantly trying to be a bro<|eor|><|sor|>Lol what?<|eor|><|eols|><|endoftext|> | 13 |
lolphp | philsturgeon | cy6p8le | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>It's kinda a fair point though. Php has improved a lot over the years, as have the practises employed by much of the community. His comment is pretty fair tbh.<|eor|><|sor|>It's not fair to call every critic of PHP an idiot. They've still not improved the ridiculous type coercion rules (and no, I'm not talking about weak typing in general; JS has weak typing, too, and I can live with it).<|eor|><|sor|>I definitively did not say that every critic of PHP is an idiot. I am a critic of PHP, and I think I'm ok. I said the people who just ignorantly blast PHP saying it cannot be used for "big websites" are idiots.
They ignore the improvements I speak of, and outlined further here:
https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy63du3
They mostly bang on about stuff that was fixed in versions of PHP years ago, comically often referencing items from phpsadness.com that have been scratched off since.
Coercion rules are a little messy for sure, but acting like the whole language is completely unusable is utterly moronic, ignorant and definitively untrue. :)<|eor|><|sor|>PHP should focus on the things that really matter. PHP still has a horrible standard library, without name-spacing, and totally broken/inconsistent function naming, parameter order etc. These are the things people care about, and use daily, these are the things NOT fixed, and these are the things that really need work.
Its not an argument to say "PHP can too be used in big websites, just look at facebook" because its kind of obvious, or should be that the language was a very poor choice from the beginning, facebook even had to re-implement the language runtime with Hack. This should raise a big red flag for anyone thinking of a bigger project that has to be supported for years to come.
<|eor|><|sor|>[Absolutely agree about the standard library](https://philsturgeon.uk/php/2013/01/26/php-6-pissing-in-the-wind/). That's one of my favourite things about working with other languages, but it's absolutely not a reason that PHP "cannot be used for big sites", it just means it's occasionally annoying and you have to google stuff.
I love that PHP 7.0 cleaned up their internals a massive amount, and I just really hope that PHP 8.0 does something about their standard lib. It'll be a big job, but somebody has to do it.
With a real spec being built by the HHVM and internals folks alike, I'm hoping FB might pump a bit of money into getting it done. It'll make their PHP developers a lot more efficient not having to google shit every five minutes.
> "PHP can too be used in big websites, just look at facebook"
I didn't use that argument. From the FB developers I've spoken to they do not regret the choice at all. They'd rather have a greater number of developers (PHP provides that) and have a small team making PHP drastically quicker (open-source yay) than spend time and money trying to hire every Scala developer in the world.
As for other large sites, if I was going to make a list here are a few:
- Uber was built on CodeIgniter
- TIME uses Drupal 7
- USA.gov uses CodeIgniter
- Bloomberg uses a bunch of PHP
- Tumblr runs PHP, think they just upgraded to 7
- Pornhub is on Symfony
- Apple does most of their internal systems in PHP
That's off the top of my head.
I'd suggest that availability of programmers is something that needs to be weighed up as much as the language itself, and the standard library being "a bit of a dick" does not outweigh that consideration.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | metamorphosis | cy5y3cq | <|sols|><|sot|>The kind of thing that gets upvoted in /r/php<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3x9wqn/why_do_people_keep_saying_php_isnt_used_for_the/cy2v9py<|eol|><|sor|>I gurantee that 95% of people here don't even come close to phils expirience.
I am all ok for PHP bashing, as sometime it deserves so... but ...the *kind of thing that gets upvoted in /t/phplol* seems more like first year comsp sciennce majors who after writing their first python script in their custom Linux and reading on forums how PHP is bad, suddley think they are better progammers.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | m1el | 3l27nz | <|sols|><|sot|>lstat syscall is too expensive, let's lie to the user<|eot|><|sol|>http://jpauli.github.io/2014/06/30/realpath-cache.html<|eol|><|eols|><|endoftext|> | 40 |
lolphp | m1el | cv2i3fx | <|sols|><|sot|>lstat syscall is too expensive, let's lie to the user<|eot|><|sol|>http://jpauli.github.io/2014/06/30/realpath-cache.html<|eol|><|soopr|> m1el@m1el:/tmp$ cat symlink.php
<?php
if (!chdir("/tmp")) {
print("failed to chdir to tmp");
die();
}
system("mkdir dir_one dir_two; touch dir_one/file.txt dir_two/file.txt");
system("ln -s dir_one lnk");
print(realpath("lnk/file.txt") . "\n");
system("rm lnk; ln -s dir_two lnk");
print(realpath("lnk/file.txt") . "\n");
system("realpath lnk/file.txt");
system("rm -r lnk dir_one dir_two");
m1el@m1el:/tmp$ php symlink.php
/tmp/dir_one/file.txt
/tmp/dir_one/file.txt
/tmp/dir_two/file.txt
<|eoopr|><|eols|><|endoftext|> | 20 |
lolphp | urquan | cv2vgfb | <|sols|><|sot|>lstat syscall is too expensive, let's lie to the user<|eot|><|sol|>http://jpauli.github.io/2014/06/30/realpath-cache.html<|eol|><|soopr|> m1el@m1el:/tmp$ cat symlink.php
<?php
if (!chdir("/tmp")) {
print("failed to chdir to tmp");
die();
}
system("mkdir dir_one dir_two; touch dir_one/file.txt dir_two/file.txt");
system("ln -s dir_one lnk");
print(realpath("lnk/file.txt") . "\n");
system("rm lnk; ln -s dir_two lnk");
print(realpath("lnk/file.txt") . "\n");
system("realpath lnk/file.txt");
system("rm -r lnk dir_one dir_two");
m1el@m1el:/tmp$ php symlink.php
/tmp/dir_one/file.txt
/tmp/dir_one/file.txt
/tmp/dir_two/file.txt
<|eoopr|><|sor|>Holy fuck I think I've hit that bug (no, sorry, I can't bring myself to use the word "feature" this time) in the past. Changing symlinks externally I couldn't figure out why it didn't work as intended in my app. Bloody wankers.<|eor|><|eols|><|endoftext|> | 20 |
lolphp | Vakieh | cv3ac5k | <|sols|><|sot|>lstat syscall is too expensive, let's lie to the user<|eot|><|sol|>http://jpauli.github.io/2014/06/30/realpath-cache.html<|eol|><|sor|>The article notes that this is a common optimization even in non-php software
> Many other softwares use a stat cache, read their source code and you'll notice that ;-)
Still. This is definitely one of those "features" that makes PHP easy to start with, but can really bite you in the ass when you discover it the hard way. <|eor|><|sor|>I wasn't aware of any other language doing this.<|eor|><|sor|>That's because it's a software or framework feature, not a language feature.
Or at least... it should be. lolphp indeed.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | merreborn | cv35v2m | <|sols|><|sot|>lstat syscall is too expensive, let's lie to the user<|eot|><|sol|>http://jpauli.github.io/2014/06/30/realpath-cache.html<|eol|><|sor|>The article notes that this is a common optimization even in non-php software
> Many other softwares use a stat cache, read their source code and you'll notice that ;-)
Still. This is definitely one of those "features" that makes PHP easy to start with, but can really bite you in the ass when you discover it the hard way. <|eor|><|eols|><|endoftext|> | 11 |
lolphp | vytah | cv4j7oz | <|sols|><|sot|>lstat syscall is too expensive, let's lie to the user<|eot|><|sol|>http://jpauli.github.io/2014/06/30/realpath-cache.html<|eol|><|sor|>[deleted]<|eor|><|sor|>
>#clearstatcache
>(PHP 4, PHP 5, PHP 7)
>clearstatcache Clears file status cache
>###Parameters
>`clear_realpath_cache`
> Whether to clear the realpath cache or not.
I think the point of this parameter is that PHP caches more than just the real path, so you may elect to clean only part of the cache, so it lies to the user *only partially*.
<|eor|><|eols|><|endoftext|> | 5 |
lolphp | realnowhereman | 2e75dx | <|sols|><|sot|>An essay on variable variables<|eot|><|sol|>http://www.reddit.com/r/programming/comments/dst56/today_i_learned_about_php_variable_variables/c12np38<|eol|><|eols|><|endoftext|> | 33 |
lolphp | robertbieber | cjx4j8r | <|sols|><|sot|>An essay on variable variables<|eot|><|sol|>http://www.reddit.com/r/programming/comments/dst56/today_i_learned_about_php_variable_variables/c12np38<|eol|><|sor|>THANKS YOU. I saw this years ago, and haven't been able to find it since<|eor|><|eols|><|endoftext|> | 7 |
lolphp | 00Davo | cjx7s43 | <|sols|><|sot|>An essay on variable variables<|eot|><|sol|>http://www.reddit.com/r/programming/comments/dst56/today_i_learned_about_php_variable_variables/c12np38<|eol|><|sor|>I know you can do this sort of magic (i.e. hacking the scope) in PowerShell and JavaScript, and I suspect that you can do it in most dynamic languages. It's very interesting to me, though I remain a staunch opponent of dynamic "typing".<|eor|><|sor|>Actually, JavaScript doesn't support doing this; it *does* let you specify a string when you're accessing a slot on an object, as in `object["someproperty"]`, but there's no way short of `eval()` to do the same thing to access variables in scope by name-as-stored-in-string. Ruby also lacks the functionality (for locals); however, you *can* get a variable-variable-esque meme in Python using `locals()["somevariable"]`.
PHP is the only language that makes doing this actual syntax, as far as I'm aware - not even bash accepts it (you have to use `eval()`)!<|eor|><|eols|><|endoftext|> | 7 |
lolphp | VeXCe | cjxcl3o | <|sols|><|sot|>An essay on variable variables<|eot|><|sol|>http://www.reddit.com/r/programming/comments/dst56/today_i_learned_about_php_variable_variables/c12np38<|eol|><|sor|>This is actually pretty cool, but I reckon there aren't enough cool things (by far) to actually create a /r/wowphp.
The only thing this needs is more regex :D<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Banane9 | cjxdrlv | <|sols|><|sot|>An essay on variable variables<|eot|><|sol|>http://www.reddit.com/r/programming/comments/dst56/today_i_learned_about_php_variable_variables/c12np38<|eol|><|sor|>This is actually pretty cool, but I reckon there aren't enough cool things (by far) to actually create a /r/wowphp.
The only thing this needs is more regex :D<|eor|><|sor|>Phew, That doesn't exist. Although it'd be fun to make it, just so it says "nothing here" :D<|eor|><|eols|><|endoftext|> | 5 |
lolphp | midir | 1vftq6 | <|sols|><|sot|>The difference that adding 0 makes<|eot|><|sol|>https://eval.in/90932<|eol|><|eols|><|endoftext|> | 38 |
lolphp | tdammers | ceru7dt | <|sols|><|sot|>The difference that adding 0 makes<|eot|><|sol|>https://eval.in/90932<|eol|><|sor|>Bit of a misleading thing going on there. The `+ 0` part doesn't just add 0, it also silently coerces from string to int. It's still broken in that the coercion rules are inconsistent and confusing (implicit coercion by addition apparently uses different rules than an explicit cast to int), but that's a somewhat lower level of breakage than the incorrect addition that the code snippet is trying to suggest.
Adding 0 "works" (or at least, it is somewhat well-defined in PHP; whether these rules make sense, and whether implicitly converting to inexact representations at platform-depended boundaries is a good design decision is yet another can of worms); it's the coercion that's broken here.
Anyway, every PHP developer worth their money knows that PHP does not really have any reliable exact numeric types anyway (because of the transparent conversion to float), and that if you want to do exact calculation on arbitrary values, you have to resort to extensions.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | destroyeraseimprove | cerv5zz | <|sols|><|sot|>The difference that adding 0 makes<|eot|><|sol|>https://eval.in/90932<|eol|><|sor|>Bit of a misleading thing going on there. The `+ 0` part doesn't just add 0, it also silently coerces from string to int. It's still broken in that the coercion rules are inconsistent and confusing (implicit coercion by addition apparently uses different rules than an explicit cast to int), but that's a somewhat lower level of breakage than the incorrect addition that the code snippet is trying to suggest.
Adding 0 "works" (or at least, it is somewhat well-defined in PHP; whether these rules make sense, and whether implicitly converting to inexact representations at platform-depended boundaries is a good design decision is yet another can of worms); it's the coercion that's broken here.
Anyway, every PHP developer worth their money knows that PHP does not really have any reliable exact numeric types anyway (because of the transparent conversion to float), and that if you want to do exact calculation on arbitrary values, you have to resort to extensions.<|eor|><|sor|>>and that if you want to do exact calculation ... you have to resort to extensions.
lel<|eor|><|eols|><|endoftext|> | 12 |
lolphp | midir | cerwcvh | <|sols|><|sot|>The difference that adding 0 makes<|eot|><|sol|>https://eval.in/90932<|eol|><|sor|>Bit of a misleading thing going on there. The `+ 0` part doesn't just add 0, it also silently coerces from string to int. It's still broken in that the coercion rules are inconsistent and confusing (implicit coercion by addition apparently uses different rules than an explicit cast to int), but that's a somewhat lower level of breakage than the incorrect addition that the code snippet is trying to suggest.
Adding 0 "works" (or at least, it is somewhat well-defined in PHP; whether these rules make sense, and whether implicitly converting to inexact representations at platform-depended boundaries is a good design decision is yet another can of worms); it's the coercion that's broken here.
Anyway, every PHP developer worth their money knows that PHP does not really have any reliable exact numeric types anyway (because of the transparent conversion to float), and that if you want to do exact calculation on arbitrary values, you have to resort to extensions.<|eor|><|soopr|>>The `+ 0` part doesn't just add 0, it also silently coerces from string to int.
Not exactly. When casting a large number from a string to an integer, the result is clamped to the range of an integer. If you do any arithmetic to it first, it turns into a *float* (because it doesn't fit in an integer), which when cast to an integer, overflows instead of clamping.<|eoopr|><|eols|><|endoftext|> | 11 |
lolphp | ceol_ | ces1jt4 | <|sols|><|sot|>The difference that adding 0 makes<|eot|><|sol|>https://eval.in/90932<|eol|><|sor|>Bit of a misleading thing going on there. The `+ 0` part doesn't just add 0, it also silently coerces from string to int. It's still broken in that the coercion rules are inconsistent and confusing (implicit coercion by addition apparently uses different rules than an explicit cast to int), but that's a somewhat lower level of breakage than the incorrect addition that the code snippet is trying to suggest.
Adding 0 "works" (or at least, it is somewhat well-defined in PHP; whether these rules make sense, and whether implicitly converting to inexact representations at platform-depended boundaries is a good design decision is yet another can of worms); it's the coercion that's broken here.
Anyway, every PHP developer worth their money knows that PHP does not really have any reliable exact numeric types anyway (because of the transparent conversion to float), and that if you want to do exact calculation on arbitrary values, you have to resort to extensions.<|eor|><|sor|>>and that if you want to do exact calculation ... you have to resort to extensions.
lel<|eor|><|sor|>Thank goodness we never have to do math!<|eor|><|eols|><|endoftext|> | 11 |
lolphp | ieccles | cervd91 | <|sols|><|sot|>The difference that adding 0 makes<|eot|><|sol|>https://eval.in/90932<|eol|><|sor|>Pardon my ignorance, but... why the hell does casting the string "4294967295" to int become 2147483647? How are those numbers related?<|eor|><|sor|>`4294967295` is the maximum value an unsigned 32 bit integer can take, and `2147483647` is the maximum value a signed 32 bit integer can take. Due to [two's complement](http://en.wikipedia.org/wiki/Two's_complement) representation, `-1` is represented as `11111111111111111111111111111111` in binary, and when this is converted to an unsigned int (the `sprintf` business), you get the maximum positive unsigned integer. Casting this to an `int` in PHP takes it from unsigned to signed, and since `4294967295` is too large to represent as a signed integer, you end up with the maximum value for a signed integer, `2147483647`.
Bit long-winded, but I hope this cleared up the choices in numbers. As another redditor pointed out, though, this is actually not PHP fumbling over simple addition so much as a sign of lower level inconsistencies in implicit type coercion.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | ceol_ | ces1kw2 | <|sols|><|sot|>The difference that adding 0 makes<|eot|><|sol|>https://eval.in/90932<|eol|><|sor|>Bit of a misleading thing going on there. The `+ 0` part doesn't just add 0, it also silently coerces from string to int. It's still broken in that the coercion rules are inconsistent and confusing (implicit coercion by addition apparently uses different rules than an explicit cast to int), but that's a somewhat lower level of breakage than the incorrect addition that the code snippet is trying to suggest.
Adding 0 "works" (or at least, it is somewhat well-defined in PHP; whether these rules make sense, and whether implicitly converting to inexact representations at platform-depended boundaries is a good design decision is yet another can of worms); it's the coercion that's broken here.
Anyway, every PHP developer worth their money knows that PHP does not really have any reliable exact numeric types anyway (because of the transparent conversion to float), and that if you want to do exact calculation on arbitrary values, you have to resort to extensions.<|eor|><|soopr|>>The `+ 0` part doesn't just add 0, it also silently coerces from string to int.
Not exactly. When casting a large number from a string to an integer, the result is clamped to the range of an integer. If you do any arithmetic to it first, it turns into a *float* (because it doesn't fit in an integer), which when cast to an integer, overflows instead of clamping.<|eoopr|><|sor|>That's pretty much what I'm saying. An explicit cast-to-int coerces by different rules than implicit conversion to a numeric value (triggered by passing a string to the numeric addition operator) - the former clamps, the latter promotes to float.<|eor|><|sor|>That looks pretty "WTF?!" to me, even after the explanation. Do you know of another language with similar behavior?<|eor|><|eols|><|endoftext|> | 6 |
lolphp | keis | cervsu7 | <|sols|><|sot|>The difference that adding 0 makes<|eot|><|sol|>https://eval.in/90932<|eol|><|sor|>And for added fun if you don't cast it to (int) in final variation you get
float(4294967295)<|eor|><|eols|><|endoftext|> | 5 |
lolphp | ismtrn | certwgr | <|sols|><|sot|>The difference that adding 0 makes<|eot|><|sol|>https://eval.in/90932<|eol|><|sor|>Wow. That is a quite cool feature.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | bozbalci | 17wcav | <|sols|><|sot|>strstr: haystack, needle, before_needle.<|eot|><|sol|>http://www.php.net/manual/en/function.strstr.php<|eol|><|eols|><|endoftext|> | 33 |
lolphp | merreborn | c89tsrn | <|sols|><|sot|>strstr: haystack, needle, before_needle.<|eot|><|sol|>http://www.php.net/manual/en/function.strstr.php<|eol|><|sor|>You should've linked to the [obviously far-superior version](http://www.php.net/manual/en/function.strstr.php#79347) posted in a comment. It's got TWO BONUS ARGUMENTS!<|eor|><|sor|>[deleted]<|eor|><|sor|>oh god. NESTED switches on boolean.
switch($before_needle){
case true:
switch($include_needle){
case true:
MAKE IT STOP MAKE IT STOP MAKE IT STOP
Jesus fucking christ, what's with the 30 calls to `chr(39)`? I guess this guy couldn't figure out how to escape single quotes?
Is there some sort of licensing board we can contact to have this guy's credentials revoked?
Back when I was introduced to PHP, I was told "The best part about PHP is all the code samples in the comments on php.net!". Now, if I ever hear a candidate echo that sentiment echoed in an interview, it's grounds for an immediate no-hire.<|eor|><|eols|><|endoftext|> | 31 |
lolphp | farsightxr20 | c89eyil | <|sols|><|sot|>strstr: haystack, needle, before_needle.<|eot|><|sol|>http://www.php.net/manual/en/function.strstr.php<|eol|><|sor|>You should've linked to the [obviously far-superior version](http://www.php.net/manual/en/function.strstr.php#79347) posted in a comment. It's got TWO BONUS ARGUMENTS!<|eor|><|eols|><|endoftext|> | 30 |
lolphp | infinull | c89j1y9 | <|sols|><|sot|>strstr: haystack, needle, before_needle.<|eot|><|sol|>http://www.php.net/manual/en/function.strstr.php<|eol|><|sor|>seems like:
list($before_needle, $after_needle) = explode($needle, $str, 2)
would be better for that use case, but maybe Python has warped my brain (in a good way?)?<|eor|><|eols|><|endoftext|> | 5 |
lolphp | guide42 | c8jphjo | <|sols|><|sot|>strstr: haystack, needle, before_needle.<|eot|><|sol|>http://www.php.net/manual/en/function.strstr.php<|eol|><|sor|>You should've linked to the [obviously far-superior version](http://www.php.net/manual/en/function.strstr.php#79347) posted in a comment. It's got TWO BONUS ARGUMENTS!<|eor|><|sor|>[deleted]<|eor|><|sor|>oh god. NESTED switches on boolean.
switch($before_needle){
case true:
switch($include_needle){
case true:
MAKE IT STOP MAKE IT STOP MAKE IT STOP
Jesus fucking christ, what's with the 30 calls to `chr(39)`? I guess this guy couldn't figure out how to escape single quotes?
Is there some sort of licensing board we can contact to have this guy's credentials revoked?
Back when I was introduced to PHP, I was told "The best part about PHP is all the code samples in the comments on php.net!". Now, if I ever hear a candidate echo that sentiment echoed in an interview, it's grounds for an immediate no-hire.<|eor|><|sor|>I been told the same thing.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Altreus | pqk6r | <|soss|><|sot|>PHP emits more warnings about accessing an array as an array than accessing a string as an array<|eot|><|sost|> $array = array( 'a' => 'a', 'b' => 'b' );
$array['a']; # OK
$array['c']; # HIDEOUS WARNING
You can't turn this warning off without turning off other, useful warnings. This warning is as often annoying as it is useful (isset ALL the keys).
$array = "whups this is a string";
$array[0]; # w
$array['a']; # ?
PHP silently converts strings to integers (apparently) and then retrieves the relevant character with NO WARNING.
Why is it less OK to want a key to optionally exist -
if ($array['a']) # any true value, non-existence is false
than it is to access a thing that isn't even an array as though it were?
Just pretend your array is actually called $content as mine is and you'll see why it's taken me so long to find my (someone else's) bug :/<|eost|><|eoss|><|endoftext|> | 35 |
lolphp | dagbrown | c3rfmg7 | <|soss|><|sot|>PHP emits more warnings about accessing an array as an array than accessing a string as an array<|eot|><|sost|> $array = array( 'a' => 'a', 'b' => 'b' );
$array['a']; # OK
$array['c']; # HIDEOUS WARNING
You can't turn this warning off without turning off other, useful warnings. This warning is as often annoying as it is useful (isset ALL the keys).
$array = "whups this is a string";
$array[0]; # w
$array['a']; # ?
PHP silently converts strings to integers (apparently) and then retrieves the relevant character with NO WARNING.
Why is it less OK to want a key to optionally exist -
if ($array['a']) # any true value, non-existence is false
than it is to access a thing that isn't even an array as though it were?
Just pretend your array is actually called $content as mine is and you'll see why it's taken me so long to find my (someone else's) bug :/<|eost|><|sor|>That's just brilliant. And by brilliant, I mean demented.
This is the sort of thing that would have been featured in the "[WAT](https://www.destroyallsoftware.com/talks/wat)" video, only that stuck exclusively to actually-*good* languages. A "WAT" video about PHP would be four hours long.<|eor|><|eoss|><|endoftext|> | 23 |
lolphp | ManchegoObfuscator | c3ricuy | <|soss|><|sot|>PHP emits more warnings about accessing an array as an array than accessing a string as an array<|eot|><|sost|> $array = array( 'a' => 'a', 'b' => 'b' );
$array['a']; # OK
$array['c']; # HIDEOUS WARNING
You can't turn this warning off without turning off other, useful warnings. This warning is as often annoying as it is useful (isset ALL the keys).
$array = "whups this is a string";
$array[0]; # w
$array['a']; # ?
PHP silently converts strings to integers (apparently) and then retrieves the relevant character with NO WARNING.
Why is it less OK to want a key to optionally exist -
if ($array['a']) # any true value, non-existence is false
than it is to access a thing that isn't even an array as though it were?
Just pretend your array is actually called $content as mine is and you'll see why it's taken me so long to find my (someone else's) bug :/<|eost|><|sor|>The PHP 'array' is the most infuriatingly passive-agressive datastructure ever.
You construct them with a keyword that looks like either a function call or a new object allocation, but then to operate on one you call the relevant function in the global namespace. Even though, under the hood it's some kind of crazy combination of a bidirectional linked list, a hashing dictionary, and a polymorphic union struct thing* -- the implementation for which also forms the basis for PHP object structures.
The fuckedupedly inconsistent warning behavior here is also inconsistent with how it works when you access object properties and methods. Which that is potentially inconsistent with 'resource' types (e.g. MySQL ResultSet references), because 'resource' means 'IDK, whatever the C implementation of this thing says'.
That last bit is especially fucking ridiculous. It's one of the many phoned-in parts of Mr. Lerdorf's opus. Contrast 'resources' with the Python C api analogue. You can, when designing boundary structures, implement a bizarre and dysfunctional Python type in C, but at the end of the day, it's still an Python type and it has to obey the basic rules of same, unless you like segfaults. The PHP extension ethos isn't even duck-punching; it is duck-impersonation by Mongoloid platypus, as like the official thing to do.
Got a bit off track there -- TL;DR I also think PHP is retarded. Blech.
* sort of like a Perl typeglob but uglier and with fewer Monty Python jokes in the inlined docs.<|eor|><|eoss|><|endoftext|> | 15 |
lolphp | Takeoded | uapav7 | <|sols|><|sot|>instead of using the standard 8 for LOCK_UN, let us invent our own value! what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/tHWuc<|eol|><|eols|><|endoftext|> | 35 |
lolphp | Denvercoder8 | i60pymb | <|sols|><|sot|>instead of using the standard 8 for LOCK_UN, let us invent our own value! what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/tHWuc<|eol|><|sor|>Yes, what could possibly go wrong?
The only issue I see here is that you're interpreting a value that's not specified by POSIX, the kernel, libc, or the PHP documentation to be a bitmask, as a bitmask. Only `LOCK_NB` is specified to be a bitmask, and that works fine in PHP.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | IluTov | i5z8yc6 | <|sols|><|sot|>instead of using the standard 8 for LOCK_UN, let us invent our own value! what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/tHWuc<|eol|><|sor|>For reference: https://github.com/php/php-src/pull/8429
This is indeed a wtf, I'll send a mail to internals to see if we can fix this for PHP 8.2.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | Takeoded | i5z4twv | <|sols|><|sot|>instead of using the standard 8 for LOCK_UN, let us invent our own value! what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/tHWuc<|eol|><|soopr|>normally LOCK_SH is 1 (1<<0) and LOCK_EX is 2 (1<<1) and LOCK_NB is 4 (1<<2) and LOCK_UN is 8 (1<<3)
BUT in PHP: LOCK_SH is 1 (1<<0) and LOCK_EX is 2 (1<<1) and LOCK_UN is 3 ((1<<0) | (1<<1)) and LOCK_NB is 4 (1<<2)<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | Takeoded | i5z953e | <|sols|><|sot|>instead of using the standard 8 for LOCK_UN, let us invent our own value! what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/tHWuc<|eol|><|sor|>For reference: https://github.com/php/php-src/pull/8429
This is indeed a wtf, I'll send a mail to internals to see if we can fix this for PHP 8.2.<|eor|><|soopr|>btw found this LOCK_UN thing because i wanted to fix another wtf for file_get_contents, the FILE_USE_INCLUDE_PATH thing, but it seems nobody gives a shit about that, ref https://marc.info/?l=php-internals&m=165070236503722&w=2<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | barubary | i6567od | <|sols|><|sot|>instead of using the standard 8 for LOCK_UN, let us invent our own value! what could possibly go wrong?<|eot|><|sol|>https://3v4l.org/tHWuc<|eol|><|soopr|>normally LOCK_SH is 1 (1<<0) and LOCK_EX is 2 (1<<1) and LOCK_NB is 4 (1<<2) and LOCK_UN is 8 (1<<3)
BUT in PHP: LOCK_SH is 1 (1<<0) and LOCK_EX is 2 (1<<1) and LOCK_UN is 3 ((1<<0) | (1<<1)) and LOCK_NB is 4 (1<<2)<|eoopr|><|sor|>> normally LOCK_SH is 1
What do you mean, "normally"?
`flock()` and its constants are not part of any standard interface. From the Linux flock(2) man page:
> **CONFORMING TO**
> 4.4BSD (the flock() call first appeared in 4.2BSD). A version of
flock(), possibly implemented in terms of fcntl(2), appears on
most UNIX systems.
Nothing I can find states that `LOCK_SH`, `LOCK_EX`, and friends should be interpretable as single bit flags.
(Similar logic applies to `open()` and the O_* constants. ISTR a system where `O_RDONLY` was 0, so testing `if (flags & O_RDONLY)` would always fail.)<|eor|><|eols|><|endoftext|> | 7 |
lolphp | nyamsprod | dq8962 | <|sols|><|sot|>DateTime::createFromFormat and DateTime::__construct default initialisation are not consistent because why not ?<|eot|><|sol|>https://3v4l.org/VVGhH<|eol|><|eols|><|endoftext|> | 36 |
lolphp | duskwuff | f61slrb | <|sols|><|sot|>DateTime::createFromFormat and DateTime::__construct default initialisation are not consistent because why not ?<|eot|><|sol|>https://3v4l.org/VVGhH<|eol|><|sor|>From the documentation for `DateTime::createFromFormat`:
> If `format` does not contain the character `!` then portions of the generated time which are not specified in `format` will be set to the current system time.
And indeed, [adding `!` to the format string gives you behavior equivalent to `DateTime::__construct`](https://3v4l.org/GUcOU).<|eor|><|eols|><|endoftext|> | 15 |
lolphp | sproingie | f66dtvh | <|sols|><|sot|>DateTime::createFromFormat and DateTime::__construct default initialisation are not consistent because why not ?<|eot|><|sol|>https://3v4l.org/VVGhH<|eol|><|soopr|>while both behaviours might be logic taken independently the lack of consistency between both methods is the real lolphp<|eoopr|><|sor|>\DateTime has enough legitimate lolphp's that the entire class counts as "the real lolphp".
Here's another one: `\DateTimeInterface::ATOM` -- you know, the one they added because `\DateTimeInterface::ISO8601` couldn't properly parse ISO8601 -- still can't parse ISO8601 timestamps containing milliseconds. I look forward to `\DateTimeInterface::REAL_ATOM` real soon now.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | nyamsprod | f614ug8 | <|sols|><|sot|>DateTime::createFromFormat and DateTime::__construct default initialisation are not consistent because why not ?<|eot|><|sol|>https://3v4l.org/VVGhH<|eol|><|soopr|>while both behaviours might be logic taken independently the lack of consistency between both methods is the real lolphp<|eoopr|><|eols|><|endoftext|> | 7 |
lolphp | duskwuff | f61sion | <|sols|><|sot|>DateTime::createFromFormat and DateTime::__construct default initialisation are not consistent because why not ?<|eot|><|sol|>https://3v4l.org/VVGhH<|eol|><|sor|>PHP datetime class is a can of worms. You dont dont want to open it.<|eor|><|sor|>Yep, it's a mess. [Carbon](https://carbon.nesbot.com/) helps a bit, but it can only do so much.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | porkslow | 7x0649 | <|sols|><|sot|>WordPress now mostly conforms to WordPress Coding Standards<|eot|><|sol|>https://make.wordpress.org/core/2017/11/30/wordpress-php-now-mostly-conforms-to-wordpress-coding-standards/<|eol|><|eols|><|endoftext|> | 35 |
lolphp | SelfDistinction | du4o825 | <|sols|><|sot|>WordPress now mostly conforms to WordPress Coding Standards<|eot|><|sol|>https://make.wordpress.org/core/2017/11/30/wordpress-php-now-mostly-conforms-to-wordpress-coding-standards/<|eol|><|sor|>On the other hand WP has an amazing track record of not leaving people behind. That's more valuable then doing hectic breaking changes <|eor|><|sor|>Yup, supporting legacy for the sake of it means there's always an old security hole out there to be found. That thing and its themes is like a Swiss cheese.<|eor|><|sor|>"Your cryptographic RNG always returns the same number" well, some people now use `gen_rng_crypto()` as a constant, so we can't break that. If you want something you can use for cryptographic purposes, use `cryptoRngRealGen()`.<|eor|><|eols|><|endoftext|> | 19 |
lolphp | Saltub | du4rpch | <|sols|><|sot|>WordPress now mostly conforms to WordPress Coding Standards<|eot|><|sol|>https://make.wordpress.org/core/2017/11/30/wordpress-php-now-mostly-conforms-to-wordpress-coding-standards/<|eol|><|sor|>Really cool coding standards like spaces immediately inside braces and all manner of other PSR-2 violations <|eor|><|eols|><|endoftext|> | 13 |
lolphp | jurgemaister | du4kasz | <|sols|><|sot|>WordPress now mostly conforms to WordPress Coding Standards<|eot|><|sol|>https://make.wordpress.org/core/2017/11/30/wordpress-php-now-mostly-conforms-to-wordpress-coding-standards/<|eol|><|sor|>On the other hand WP has an amazing track record of not leaving people behind. That's more valuable then doing hectic breaking changes <|eor|><|sor|>Yup, supporting legacy for the sake of it means there's always an old security hole out there to be found. That thing and its themes is like a Swiss cheese.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | porkslow | du6bhf0 | <|sols|><|sot|>WordPress now mostly conforms to WordPress Coding Standards<|eot|><|sol|>https://make.wordpress.org/core/2017/11/30/wordpress-php-now-mostly-conforms-to-wordpress-coding-standards/<|eol|><|sor|>What's the LOL here?
<|eor|><|soopr|>WP core developers have had these standards for at least 5 years but actually never bothered the follow them by themselves.<|eoopr|><|eols|><|endoftext|> | 6 |
lolphp | bart2019 | du6bczi | <|sols|><|sot|>WordPress now mostly conforms to WordPress Coding Standards<|eot|><|sol|>https://make.wordpress.org/core/2017/11/30/wordpress-php-now-mostly-conforms-to-wordpress-coding-standards/<|eol|><|sor|>What's the LOL here?
<|eor|><|eols|><|endoftext|> | 5 |
lolphp | deusex_ | du4g1tc | <|sols|><|sot|>WordPress now mostly conforms to WordPress Coding Standards<|eot|><|sol|>https://make.wordpress.org/core/2017/11/30/wordpress-php-now-mostly-conforms-to-wordpress-coding-standards/<|eol|><|sor|>On the other hand WP has an amazing track record of not leaving people behind. That's more valuable then doing hectic breaking changes <|eor|><|eols|><|endoftext|> | 5 |
lolphp | nindustries | 7mln8t | <|soss|><|sot|>Even with type hinting, 'false' on an INT argument will give you zero<|eot|><|sost|>false is type bool
0 is type int
<|eost|><|eoss|><|endoftext|> | 33 |
lolphp | Various_Pickles | drvz63d | <|soss|><|sot|>Even with type hinting, 'false' on an INT argument will give you zero<|eot|><|sost|>false is type bool
0 is type int
<|eost|><|sor|>Hinting does not a type system make.
PHP type hints are like annotations in other languages, except drawn on a cardboard sign held by a homeless guy masturbating on the subway.<|eor|><|eoss|><|endoftext|> | 16 |
lolphp | prewk | druw9id | <|soss|><|sot|>Even with type hinting, 'false' on an INT argument will give you zero<|eot|><|sost|>false is type bool
0 is type int
<|eost|><|sor|>That's pretty weird actually: https://3v4l.org/b8gQ2
Didn't know type hinting triggered type coercion.<|eor|><|eoss|><|endoftext|> | 11 |
lolphp | Takeoded | druy3hw | <|soss|><|sot|>Even with type hinting, 'false' on an INT argument will give you zero<|eot|><|sost|>false is type bool
0 is type int
<|eost|><|sor|>That's pretty weird actually: https://3v4l.org/b8gQ2
Didn't know type hinting triggered type coercion.<|eor|><|sor|>at least it's optional. `declare(strict_types=1);`turns it off. (except with a special case for int->float) - but inside the function, the variable is guaranteed to be the type you specified in the type hint.
`function f(int $i){return is_int($i);}` is always true.<|eor|><|eoss|><|endoftext|> | 11 |
lolphp | Idontremember99 | drv15cg | <|soss|><|sot|>Even with type hinting, 'false' on an INT argument will give you zero<|eot|><|sost|>false is type bool
0 is type int
<|eost|><|sor|>That's pretty weird actually: https://3v4l.org/b8gQ2
Didn't know type hinting triggered type coercion.<|eor|><|sor|>And it worked as expected for 5.6<|eor|><|sor|>No, it didn't since int was treated as a class name not the scalar type: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration.types<|eor|><|eoss|><|endoftext|> | 11 |
lolphp | the_alias_of_andrea | drv6wf1 | <|soss|><|sot|>Even with type hinting, 'false' on an INT argument will give you zero<|eot|><|sost|>false is type bool
0 is type int
<|eost|><|sor|>That's pretty weird actually: https://3v4l.org/b8gQ2
Didn't know type hinting triggered type coercion.<|eor|><|sor|>It's what the built-in functions do, and it fits with the rest of the language, and so I made userland type declarations behave similarly by default (null is special-cased to not coerce though, because that is a bit of a mess).<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | przemo_li | dscye0i | <|soss|><|sot|>Even with type hinting, 'false' on an INT argument will give you zero<|eot|><|sost|>false is type bool
0 is type int
<|eost|><|sor|>It makes perfect sense.
PHP do implicit type coercion. Type hinting thus only guarantee end result is correct value of given (pseudo)type, nothing more.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | 6f944ee6 | 5ywcig | <|sols|><|sot|>Wait, you can't call the return value of a function in one expression<|eot|><|sol|>https://3v4l.org/27QQ7<|eol|><|eols|><|endoftext|> | 35 |
lolphp | coredumperror | detq9r5 | <|sols|><|sot|>Wait, you can't call the return value of a function in one expression<|eot|><|sol|>https://3v4l.org/27QQ7<|eol|><|sor|>Before 5.4 (I think? Could have been 5.5), you couldn't even *index into* the return value of a function. So if your function returned an array, but you only cared about one element, you had to save the return into a variable before you could extract the value you wanted.<|eor|><|eols|><|endoftext|> | 30 |
lolphp | ciaranmcnulty | dets67i | <|sols|><|sot|>Wait, you can't call the return value of a function in one expression<|eot|><|sol|>https://3v4l.org/27QQ7<|eol|><|sor|>Surely this title should be "Before 2015 you couldn't..."<|eor|><|eols|><|endoftext|> | 13 |
lolphp | nikic | detw9bo | <|sols|><|sot|>Wait, you can't call the return value of a function in one expression<|eot|><|sol|>https://3v4l.org/27QQ7<|eol|><|sor|>You can, as of PHP 7 ([UVS RFC](https://wiki.php.net/rfc/uniform_variable_syntax)).<|eor|><|eols|><|endoftext|> | 13 |
lolphp | FuckTheCharacterLimi | detj5nx | <|sols|><|sot|>Wait, you can't call the return value of a function in one expression<|eot|><|sol|>https://3v4l.org/27QQ7<|eol|><|sor|>Even just wrapping a function in parentheses gives the same result:
<?php
$f = function() { echo "LOL PHP"; };
($f)();
> Output for hhvm-3.12.14 - 3.18.1, 7.0.0 - 7.1.2
>LOL PHP
#
>Output for 5.6.0 - 5.6.30
>Parse error: syntax error, unexpected '(' in /in/JSRXd on line 6
>Process exited with code 255.
So I guess any expression that evaluates to a function can't be called, you have to assign it to a variable and call that.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | Liorithiel | detwv23 | <|sols|><|sot|>Wait, you can't call the return value of a function in one expression<|eot|><|sol|>https://3v4l.org/27QQ7<|eol|><|sor|>Before 5.4 (I think? Could have been 5.5), you couldn't even *index into* the return value of a function. So if your function returned an array, but you only cared about one element, you had to save the return into a variable before you could extract the value you wanted.<|eor|><|sor|>The same problem annoys me each time I have to write anything nontrivial in MATLAB. It's a terrible language.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | the_alias_of_andrea | deug5yc | <|sols|><|sot|>Wait, you can't call the return value of a function in one expression<|eot|><|sol|>https://3v4l.org/27QQ7<|eol|><|sor|>I suppose we should take it as a mark of pride that /r/lolphp is resorting to complaining about things we already fixed. :p<|eor|><|eols|><|endoftext|> | 6 |
lolphp | jesseschalken | deu0s1u | <|sols|><|sot|>Wait, you can't call the return value of a function in one expression<|eot|><|sol|>https://3v4l.org/27QQ7<|eol|><|sor|>Surely this title should be "Before 2015 you couldn't..."<|eor|><|sor|>I think there's a legitimate lolphp here in that it to so long for it to be fixed.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | myaut | 5wfyqn | <|sols|><|sot|>Unlike existing PECL libsodium module which uses \Sodium namespace, functions will be renamed to sodium_* for inclusion in 7.2<|eot|><|sol|>https://wiki.php.net/rfc/libsodium<|eol|><|eols|><|endoftext|> | 38 |
lolphp | xiongchiamiov | dea1wup | <|sols|><|sot|>Unlike existing PECL libsodium module which uses \Sodium namespace, functions will be renamed to sodium_* for inclusion in 7.2<|eot|><|sol|>https://wiki.php.net/rfc/libsodium<|eol|><|sor|>To be fair, PHP namespaces are fucking ugly.<|eor|><|eols|><|endoftext|> | 23 |
lolphp | yxpow | deavktp | <|sols|><|sot|>Unlike existing PECL libsodium module which uses \Sodium namespace, functions will be renamed to sodium_* for inclusion in 7.2<|eot|><|sol|>https://wiki.php.net/rfc/libsodium<|eol|><|sor|>To be fair, PHP namespaces are fucking ugly.<|eor|><|sor|>'\' was probably the only free token they could use, since if they used `.` or `::` it'd probably introduce some weird as hell bugs.<|eor|><|eols|><|endoftext|> | 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.