subreddit
stringclasses 7
values | author
stringlengths 3
20
| id
stringlengths 5
7
| content
stringlengths 67
30.4k
| score
int64 0
140k
|
---|---|---|---|---|
lolphp | EleventyTwatWaffles | e0dlk0c | <|sols|><|sot|>PHP as a profession<|eot|><|sol|>http://php.net/manual/en/function.delete.php<|eol|><|sor|>Okay, what am I missing here?
Woosh?<|eor|><|sor|>Probably the fact that they hade to add a page with a dummy delete method, becuase of <PHP dev><|eor|><|sor|>Sounds like bitching for bitchings sake, or karma. <|eor|><|eols|><|endoftext|> | 28 |
lolphp | cleeder | e0dnzjp | <|sols|><|sot|>PHP as a profession<|eot|><|sol|>http://php.net/manual/en/function.delete.php<|eol|><|sor|>Okay, what am I missing here?
Woosh?<|eor|><|sor|>Probably the fact that they hade to add a page with a dummy delete method, becuase of <PHP dev><|eor|><|sor|>Eeeeeh. I could not care less on this, honestly. It's there to be helpful. `unlink()` isn't what most people would search for when looking to delete a file, but it _is_ named aptly as it is a passthrough to the underlying system `unlink`.
This is just more bitching about PHP's API conventions (or lack thereof), which has been done to death.<|eor|><|eols|><|endoftext|> | 23 |
lolphp | notaaron | e0dm6nm | <|sols|><|sot|>PHP as a profession<|eot|><|sol|>http://php.net/manual/en/function.delete.php<|eol|><|sor|>Tbh, I dont think this is too bad.<|eor|><|eols|><|endoftext|> | 22 |
lolphp | cleeder | e0e4jkm | <|sols|><|sot|>PHP as a profession<|eot|><|sol|>http://php.net/manual/en/function.delete.php<|eol|><|sor|>We probably will get a real_delete soon. Or real_print_r that wont actually cause side-effects. Another gem for the taking...<|eor|><|sor|>I'm really tired of hearing this. This isn't an lolphp. The `mysql_real_escape_string()` function is named to directly map to, like every other MySQL function, [the MySQL C API function _of the same name_](https://dev.mysql.com/doc/refman/5.7/en/mysql-real-escape-string.html).
There are plenty of reasons to pick on PHP. This isn't one of them.<|eor|><|eols|><|endoftext|> | 22 |
lolphp | cleeder | e0dkfe9 | <|sols|><|sot|>PHP as a profession<|eot|><|sol|>http://php.net/manual/en/function.delete.php<|eol|><|sor|>Okay, what am I missing here?
Woosh?<|eor|><|eols|><|endoftext|> | 16 |
lolphp | TorbenKoehn | e0ho1fy | <|sols|><|sot|>PHP as a profession<|eot|><|sol|>http://php.net/manual/en/function.delete.php<|eol|><|sor|>We probably will get a real_delete soon. Or real_print_r that wont actually cause side-effects. Another gem for the taking...<|eor|><|sor|>I'm really tired of hearing this. This isn't an lolphp. The `mysql_real_escape_string()` function is named to directly map to, like every other MySQL function, [the MySQL C API function _of the same name_](https://dev.mysql.com/doc/refman/5.7/en/mysql-real-escape-string.html).
There are plenty of reasons to pick on PHP. This isn't one of them.<|eor|><|sor|>True, but copying the C API names directly all over the place (like all of the str* functions) is a lolphp, IMO.<|eor|><|sor|>At the time PHP was created these function names were really common in many languages, why would this be a lolphp? Why would you want them to rename all functions? Just to break all applications and have every single person re\-code all of it?<|eor|><|eols|><|endoftext|> | 6 |
lolphp | sickjobpeople | 3vzwvw | <|sols|><|sot|>The controversial PSR-6 has passed. Disregarding significant push-back from the community and largest projects.<|eot|><|sol|>https://groups.google.com/d/msg/php-fig/dSw5IhpKJ1g/WqITQoNACAAJ<|eol|><|eols|><|endoftext|> | 2 |
lolphp | RainOnYourTirade | 3kcgjv | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|eols|><|endoftext|> | 2 |
lolphp | vytah | cuwmwc8 | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|sor|>This is actually not *that* bad:
1. The first case obviously makes sense, no doubts about it
2. The second one does too: when you join a list of strings with a separator and the list has one element, the result will have no separators. Exploding is the inverse of joining.
3. Since it makes no sense to have a join of an empty list of strings (I'll elaborate later), the argument for the join function should be a non-empty list. Conversely, the result of explode should be a valid argument for join, so it should be non-empty. Nothing weird here.
4. Exploding with an empty separator is not well-defined it has infinitely many solutions, with arbitrary number of empty strings in the result. There are multiple sensible ways to solve this: throw an exception, return a one-element list with the original string, explode the string into multiple 1-character strings. Here PHP chose something different (as it always does) it returns a value of a totally unrelated type and hopes you notice it.
---
Now about maths about exploding and joining: we want the following properties from them (*J* join, **X** explode, *s* some non-empty separator, *a*,*b*,*c*,... strings, **A**,**B**,**C**... lists of strings, dot string or list concatenation):
* *J*(**X**(*a*, *s*), *s*) = *a* exploding and joining should give back the original string
* *J*(**[***a*, *b***]**, *s*) = *a* *s* *b* joining two elements puts a separator between them
* *J*(**A** **B**, *s*) = *J*(**A**, *s*) *s* *J*(**B**, *s*) joining a concatenation of two lists concatenates joins of them and puts a separator between them
First, let's prove that *J*(**[***a***]**, *s*) = *a* makes sense:
*J*(**[***a***]**, *s*) *s* J(**[***b***]**, *s*)
= *J*(**[***a***]** **[***b***]**, *s*)
= *J*(**[***a*, *b***]**, *s*)
= *a* *s* *b*
And then I can prove that there's no result for joining an empty list:
if *J*(**[]**, *s*) = *z*, then for any **A**:
*x* = *J*(**A**, *s*)
= *J*(**[]** **A**, *s*)
= *J*(**[]**, *s*) *s* *J*(**A**, *s*)
= *z* *s* *x*, which is a contradiction
Also it's easy to show that joining a list of a size other than one guarantees to return a string that contains the separator. Therefore, if *a* does not contain the separator *s*, and **A** = **X**(*a*, *s*), and we want to have *J*(**A**, *s*) = *a*, then the only possibility is for **A** to have one element: *A* = **[***x***]**. We have *J*(**[***x***]**, *s*) = *x*, so **A** = **[***a***]** for every *a*, including the empty string.
---
TL;DR: Only the last example is lolphp.<|eor|><|eols|><|endoftext|> | 34 |
lolphp | tdammers | cuwkb5z | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|soopr|>To reference the documentation:
> Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter.
> If delimiter is an empty string (""), explode() will return FALSE. If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned.
Were they high when they designed this language?<|eoopr|><|sor|>They didn't design the language, it happened by accident.<|eor|><|eols|><|endoftext|> | 33 |
lolphp | tdammers | cuwkb17 | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|sor|>Well. It's called `explode()` for a reason. If it made sense, they'd have called it `split()` :-)<|eor|><|sor|>They didn't call it `split`, because they already had a lot of 5-letter function names, so that would have been a performance issue. (Not kidding.)<|eor|><|eols|><|endoftext|> | 31 |
lolphp | andsens | cuwhzay | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|sor|>Well. It's called `explode()` for a reason. If it made sense, they'd have called it `split()` :-)<|eor|><|eols|><|endoftext|> | 21 |
lolphp | RainOnYourTirade | cuwelnp | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|soopr|>To reference the documentation:
> Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter.
> If delimiter is an empty string (""), explode() will return FALSE. If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned.
Were they high when they designed this language?<|eoopr|><|eols|><|endoftext|> | 20 |
lolphp | tdammers | cuwm2ii | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|sor|>Well. It's called `explode()` for a reason. If it made sense, they'd have called it `split()` :-)<|eor|><|sor|>They didn't call it `split`, because they already had a lot of 5-letter function names, so that would have been a performance issue. (Not kidding.)<|eor|><|sor|>And as every PHP programmer knows, good hash functions were only invented in 2012<|eor|><|sor|>What are you talking about? `strlen` is a perfectly fine hashing function!<|eor|><|eols|><|endoftext|> | 17 |
lolphp | expugnator3000 | cuwkw4r | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|sor|>Well. It's called `explode()` for a reason. If it made sense, they'd have called it `split()` :-)<|eor|><|sor|>They didn't call it `split`, because they already had a lot of 5-letter function names, so that would have been a performance issue. (Not kidding.)<|eor|><|sor|>And as every PHP programmer knows, good hash functions were only invented in 2012<|eor|><|eols|><|endoftext|> | 16 |
lolphp | Artemis2 | cuwk6x6 | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|soopr|>To reference the documentation:
> Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter.
> If delimiter is an empty string (""), explode() will return FALSE. If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned.
Were they high when they designed this language?<|eoopr|><|sor|>I'm so tired of shitposts like this. How ignorant do you have to be to say that this is an issue? This isn't "lolphp", this is more of a "lol php manual". Further, the manual itself was written by some guy, so it's *really* a "lol person", who may or may not still be involved with the development of php and/or it's corresponding documentation, so this is **really** just a general "lol" that is in no way/shape/form related to PHP itself. Just offering my opinion as an expert. I'm *totally* not a butthurt php fanboy lurking around this sub. Honest.
EDIT: I think I've proven my point. I'm done with this thread.
EDIT 2: If it were so bad, why is it the most used language for web programming? Checkmate. I'm done.
EDIT 3: You don't **have** to use the defaults. They can be modified in php.ini. Bye now.
EDIT 4: Yeah well, a lot of other languages don't do that either. Are they all broken as well? /thread
EDIT 5: That's explained in the docs, so it's not a bug. Peace out.<|eor|><|sor|>Username is relevant.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | Banane9 | cuwkap4 | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|soopr|>To reference the documentation:
> Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter.
> If delimiter is an empty string (""), explode() will return FALSE. If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned.
Were they high when they designed this language?<|eoopr|><|sor|>I'm so tired of shitposts like this. How ignorant do you have to be to say that this is an issue? This isn't "lolphp", this is more of a "lol php manual". Further, the manual itself was written by some guy, so it's *really* a "lol person", who may or may not still be involved with the development of php and/or it's corresponding documentation, so this is **really** just a general "lol" that is in no way/shape/form related to PHP itself. Just offering my opinion as an expert. I'm *totally* not a butthurt php fanboy lurking around this sub. Honest.
EDIT: I think I've proven my point. I'm done with this thread.
EDIT 2: If it were so bad, why is it the most used language for web programming? Checkmate. I'm done.
EDIT 3: You don't **have** to use the defaults. They can be modified in php.ini. Bye now.
EDIT 4: Yeah well, a lot of other languages don't do that either. Are they all broken as well? /thread
EDIT 5: That's explained in the docs, so it's not a bug. Peace out.<|eor|><|sor|>How did /u/phpapologist_SS get on here?<|eor|><|eols|><|endoftext|> | 11 |
lolphp | ReversedGif | cux123p | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|sor|>Pretty much all of this makes sense. You should feel ashamed of yourself.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | polish_niceguy | cuwpew5 | <|sols|><|sot|>explode() is a mess<|eot|><|sol|>https://3v4l.org/eKMav<|eol|><|soopr|>To reference the documentation:
> Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter.
> If delimiter is an empty string (""), explode() will return FALSE. If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned.
Were they high when they designed this language?<|eoopr|><|sor|>I'm so tired of shitposts like this. How ignorant do you have to be to say that this is an issue? This isn't "lolphp", this is more of a "lol php manual". Further, the manual itself was written by some guy, so it's *really* a "lol person", who may or may not still be involved with the development of php and/or it's corresponding documentation, so this is **really** just a general "lol" that is in no way/shape/form related to PHP itself. Just offering my opinion as an expert. I'm *totally* not a butthurt php fanboy lurking around this sub. Honest.
EDIT: I think I've proven my point. I'm done with this thread.
EDIT 2: If it were so bad, why is it the most used language for web programming? Checkmate. I'm done.
EDIT 3: You don't **have** to use the defaults. They can be modified in php.ini. Bye now.
EDIT 4: Yeah well, a lot of other languages don't do that either. Are they all broken as well? /thread
EDIT 5: That's explained in the docs, so it's not a bug. Peace out.<|eor|><|sor|>Not sure if serious or Poe's law.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | jamwaffles | 1q3byu | <|sols|><|sot|>PHP is the only language that will bankrupt Microsoft<|eot|><|sol|>https://hackerone.com/ibb<|eol|><|eols|><|endoftext|> | 4 |
lolphp | BufferUnderpants | cd9a9yd | <|sols|><|sot|>PHP is the only language that will bankrupt Microsoft<|eot|><|sol|>https://hackerone.com/ibb<|eol|><|sor|>Hahaha, PHP is so vulnerable that the bug bounties will cost Microsoft billions of dollars.
Seriously, unless the post actually has something funny about PHP, why the fuck would you post it here? Might as well make /r/lolphpcirclejerk while I'm at it.<|eor|><|sor|>I wanted that to be a real subreddit. <|eor|><|sor|>It'd be rather redundant, to be had.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | BufferUnderpants | cd8wgww | <|sols|><|sot|>PHP is the only language that will bankrupt Microsoft<|eot|><|sol|>https://hackerone.com/ibb<|eol|><|sor|>Hahaha, PHP is so vulnerable that the bug bounties will cost Microsoft billions of dollars.
Seriously, unless the post actually has something funny about PHP, why the fuck would you post it here? Might as well make /r/lolphpcirclejerk while I'm at it.<|eor|><|sor|>[removed]<|eor|><|sor|> back to /b/, please<|eor|><|eols|><|endoftext|> | 6 |
lolphp | cythrawll | ww2bx | <|sols|><|sot|>CodeAngel.org PHP frameworks are obsolete<|eot|><|sol|>http://codeangel.org/articles/php-frameworks-are-obsolete.html<|eol|><|eols|><|endoftext|> | 2 |
lolphp | nakudoh | qzdbi | <|sols|><|sot|>2037 latest year???<|eot|><|sol|>https://bugs.php.net/bug.php?id=7103<|eol|><|eols|><|endoftext|> | 3 |
lolphp | RobOplawar | c41nrlo | <|sols|><|sot|>2037 latest year???<|eot|><|sol|>https://bugs.php.net/bug.php?id=7103<|eol|><|sor|>This is a well known problem with using 32 bit unix timestamps:
http://en.m.wikipedia.org/wiki/Year_2038_problem
It's not unique to PHP. <|eor|><|eols|><|endoftext|> | 12 |
lolphp | nakudoh | c41nkx4 | <|sols|><|sot|>2037 latest year???<|eot|><|sol|>https://bugs.php.net/bug.php?id=7103<|eol|><|soopr|>So I had to parse a X.509 certificate that is valid until 2040.
Sorry, not possible in PHP.<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | ealf | d6by1 | <|soss|><|sot|>$foo ? new A() : new B(); class A extends B {} class B {}<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 2 |
lolphp | ealf | cjia1 | <|soss|><|sot|>If __toString() throws an exception, you (a) don't get to catch it, (b) don't get a stack trace, and (c) it's reported as being on LINE 0.<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 2 |
lolphp | ealf | cgjz7 | <|soss|><|sot|>new Foo()->bar() doesn't parse<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 2 |
lolphp | ealf | ccyu4 | <|soss|><|sot|>$x = '_SERVER'; print_r($$x);<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 2 |
lolphp | ealf | cat6w | <|soss|><|sot|>a?b:c?d:e means (a?b:c)?d:e<|eot|><|sost|>... because we don't understand what associativity is but we write parsers anyway<|eost|><|eoss|><|endoftext|> | 2 |
lolphp | ealf | cat67 | <|soss|><|sot|>08 === 0<|eot|><|sost|>... because noone checked the return value of `atol()`<|eost|><|eoss|><|endoftext|> | 2 |
lolphp | Persism | s9yob9 | <|sols|><|sot|>How I got foiled by PHP's deceptive Frankenstein "dictionary or list" array and broke a production system<|eot|><|sol|>https://vazaha.blog/en/9/php-frankenstein-arrays<|eol|><|eols|><|endoftext|> | 1 |
lolphp | Altreus | htq62be | <|sols|><|sot|>How I got foiled by PHP's deceptive Frankenstein "dictionary or list" array and broke a production system<|eot|><|sol|>https://vazaha.blog/en/9/php-frankenstein-arrays<|eol|><|sor|>PHP believes that numbers are numeric, which is foolish in the extreme. The textbook new-programmer mistake is to create a number field to store a telephone number; we all know that it's really text that happens to only contain numbers.
And this is the fundamental difference between arrays and dictionaries: dictionaries' keys are strings, regardless of the data type used. It is completely impossible to guess what the user meant, and a language should not even be attempting to do so.
PHP is characterised by this. Most of its bad design decisions are just mistakes that new programmers make.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | Altreus | htq9pd2 | <|sols|><|sot|>How I got foiled by PHP's deceptive Frankenstein "dictionary or list" array and broke a production system<|eot|><|sol|>https://vazaha.blog/en/9/php-frankenstein-arrays<|eol|><|sor|>PHP believes that numbers are numeric, which is foolish in the extreme. The textbook new-programmer mistake is to create a number field to store a telephone number; we all know that it's really text that happens to only contain numbers.
And this is the fundamental difference between arrays and dictionaries: dictionaries' keys are strings, regardless of the data type used. It is completely impossible to guess what the user meant, and a language should not even be attempting to do so.
PHP is characterised by this. Most of its bad design decisions are just mistakes that new programmers make.<|eor|><|sor|>100% this article is actually loldev as they don't get it<|eor|><|sor|>No this is PHP at fault for sure<|eor|><|sor|>
https://www.php.net/manual/en/function.json-decode.php
You can json_decode with an associative array by passing in true as a second param, author didn't even know what he was doing<|eor|><|sor|>Irrelevant. These data structures are incompatible. Languages are supposed to protect you from obvious mistakes, not encourage them.
You know, like making you declare variables so you don't spell them wrong or accidentally overwrite them.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | loptr | htr3bje | <|sols|><|sot|>How I got foiled by PHP's deceptive Frankenstein "dictionary or list" array and broke a production system<|eot|><|sol|>https://vazaha.blog/en/9/php-frankenstein-arrays<|eol|><|sor|>PHP believes that numbers are numeric, which is foolish in the extreme. The textbook new-programmer mistake is to create a number field to store a telephone number; we all know that it's really text that happens to only contain numbers.
And this is the fundamental difference between arrays and dictionaries: dictionaries' keys are strings, regardless of the data type used. It is completely impossible to guess what the user meant, and a language should not even be attempting to do so.
PHP is characterised by this. Most of its bad design decisions are just mistakes that new programmers make.<|eor|><|sor|>100% this article is actually loldev as they don't get it<|eor|><|sor|>No this is PHP at fault for sure<|eor|><|sor|>
https://www.php.net/manual/en/function.json-decode.php
You can json_decode with an associative array by passing in true as a second param, author didn't even know what he was doing<|eor|><|sor|>But even when parsing the JSON to an associative array using the second argument it's reasonable to expect the keys to be (remain) strings, but that's a language wide behavior though so indeed a knowledge issue and not a scenario specific gotcha.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | vytah | htsplhw | <|sols|><|sot|>How I got foiled by PHP's deceptive Frankenstein "dictionary or list" array and broke a production system<|eot|><|sol|>https://vazaha.blog/en/9/php-frankenstein-arrays<|eol|><|sor|>PHP believes that numbers are numeric, which is foolish in the extreme. The textbook new-programmer mistake is to create a number field to store a telephone number; we all know that it's really text that happens to only contain numbers.
And this is the fundamental difference between arrays and dictionaries: dictionaries' keys are strings, regardless of the data type used. It is completely impossible to guess what the user meant, and a language should not even be attempting to do so.
PHP is characterised by this. Most of its bad design decisions are just mistakes that new programmers make.<|eor|><|sor|>> The textbook new-programmer mistake is to create a number field to store a telephone number;
This is mostly due to the quirk of the English language that conflates two completely different meanings of the word _number_. A native German speaker is much less likely to confuse _Nummer_ and _Zahl_.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | boxhacker | htq7lqc | <|sols|><|sot|>How I got foiled by PHP's deceptive Frankenstein "dictionary or list" array and broke a production system<|eot|><|sol|>https://vazaha.blog/en/9/php-frankenstein-arrays<|eol|><|sor|>PHP believes that numbers are numeric, which is foolish in the extreme. The textbook new-programmer mistake is to create a number field to store a telephone number; we all know that it's really text that happens to only contain numbers.
And this is the fundamental difference between arrays and dictionaries: dictionaries' keys are strings, regardless of the data type used. It is completely impossible to guess what the user meant, and a language should not even be attempting to do so.
PHP is characterised by this. Most of its bad design decisions are just mistakes that new programmers make.<|eor|><|sor|>100% this article is actually loldev as they don't get it<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Green-Look | epk1lt | <|soss|><|sot|>Instead of complaining about PHP. Why not use Laravel?<|eot|><|sost|>It solves most of what is wrong with PHP, instead of easily solving your problems, you enjoy bashing PHP with your elitist attitude. Grow up.<|eost|><|eoss|><|endoftext|> | 1 |
lolphp | tdammers | fejy9o3 | <|soss|><|sot|>Instead of complaining about PHP. Why not use Laravel?<|eot|><|sost|>It solves most of what is wrong with PHP, instead of easily solving your problems, you enjoy bashing PHP with your elitist attitude. Grow up.<|eost|><|sor|>No it doesn't. It's a laudeable effort, but it doesn't fix what is wrong with PHP.<|eor|><|eoss|><|endoftext|> | 22 |
lolphp | Perdouille | fekbat3 | <|soss|><|sot|>Instead of complaining about PHP. Why not use Laravel?<|eot|><|sost|>It solves most of what is wrong with PHP, instead of easily solving your problems, you enjoy bashing PHP with your elitist attitude. Grow up.<|eost|><|sor|>I follow LolPHP but I'm a PHP dev. It's useful to learn quirks of the language if you want to be a good dev.
Not everyone on /r/lolphp is an elitist prick<|eor|><|eoss|><|endoftext|> | 21 |
lolphp | sproingie | felrxg5 | <|soss|><|sot|>Instead of complaining about PHP. Why not use Laravel?<|eot|><|sost|>It solves most of what is wrong with PHP, instead of easily solving your problems, you enjoy bashing PHP with your elitist attitude. Grow up.<|eost|><|sor|>Laravel's use of magic methods _adds_ all kinds of WTFs to PHP development. To say nothing of the immense overhead of the dependency injection indirections that have to be calculated on _every single request_ because of PHP's architecture. There's a reason laravel sits at the bottom of almost every web framework benchmark.
Laravel's collections are pretty nice though. But I can get the same in a language that's actually designed with concepts after 1990 in mind. Concepts like unicode. And asynchronous programming. And running for longer than one request at a time.<|eor|><|eoss|><|endoftext|> | 16 |
lolphp | barubary | feqq6k5 | <|soss|><|sot|>Instead of complaining about PHP. Why not use Laravel?<|eot|><|sost|>It solves most of what is wrong with PHP, instead of easily solving your problems, you enjoy bashing PHP with your elitist attitude. Grow up.<|eost|><|sor|>Instead of complaining about the US, why not move to Mississippi?<|eor|><|eoss|><|endoftext|> | 10 |
lolphp | sproingie | felt0qe | <|soss|><|sot|>Instead of complaining about PHP. Why not use Laravel?<|eot|><|sost|>It solves most of what is wrong with PHP, instead of easily solving your problems, you enjoy bashing PHP with your elitist attitude. Grow up.<|eost|><|sor|>I follow LolPHP but I'm a PHP dev. It's useful to learn quirks of the language if you want to be a good dev.
Not everyone on /r/lolphp is an elitist prick<|eor|><|sor|>It's good to meet you, sir. I detest the language you develop, because I feel absolutely hobbled and bemused with its misbehaviors and limitations when having to work with it. I do however appreciate the recent attempts to evolve it -- the static typing stuff seems a particularly nice evolution. But it can't overcome the basic shortcomings of the language: the whole .ini file business, the inconsistencies in function naming, arguments, behaviors. Fatal and uncatchable "warnings". It keeps going.
PHP doesn't so much need a new language so much as to just turf the crap in the global namespace and start over with sensible behavior in modules (real modules, not hacked string-prefix namespaces). And a runtime that supports sanity by default. `use strict;` dammit (and don't make it a string or a magic comment)
Edit: I somehow read "I'm a PHP dev" as "I'm a dev on the PHP language". I'm guessing that's not the case? Would be nice to have core PHP devs with their asbestos undies on chime in. Maybe in a moderated disussion.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | phplovesong | c1m7tj | <|soss|><|sot|>Calling a method on StdClass always returns FATAL ERROR<|eot|><|sost|>Some sites like [lolphptherightway](https://phptherightway.com/pages/Functional-Programming.html) is trying to spread lies about first class functions. But attaching functions to stdClass is allowed, but one cant call them. Its pure lolphp all the way down.
https://repl.it/repls/SpecializedAngryBrains<|eost|><|eoss|><|endoftext|> | 1 |
lolphp | jesseschalken | ereh2m8 | <|soss|><|sot|>Calling a method on StdClass always returns FATAL ERROR<|eot|><|sost|>Some sites like [lolphptherightway](https://phptherightway.com/pages/Functional-Programming.html) is trying to spread lies about first class functions. But attaching functions to stdClass is allowed, but one cant call them. Its pure lolphp all the way down.
https://repl.it/repls/SpecializedAngryBrains<|eost|><|sor|>Properties and methods belong to different namespaces, and a different syntax is used for each. Java is the same.
`$foo->bar()` is strictly a method call, not a property access. To call a property as a function you use `($foo->bar)()`.<|eor|><|eoss|><|endoftext|> | 21 |
lolphp | ntzm_ | erefyu5 | <|soss|><|sot|>Calling a method on StdClass always returns FATAL ERROR<|eot|><|sost|>Some sites like [lolphptherightway](https://phptherightway.com/pages/Functional-Programming.html) is trying to spread lies about first class functions. But attaching functions to stdClass is allowed, but one cant call them. Its pure lolphp all the way down.
https://repl.it/repls/SpecializedAngryBrains<|eost|><|sor|>Yes you can, you're just doing it wrong :)<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | SirClueless | ere4vee | <|soss|><|sot|>Calling a method on StdClass always returns FATAL ERROR<|eot|><|sost|>Some sites like [lolphptherightway](https://phptherightway.com/pages/Functional-Programming.html) is trying to spread lies about first class functions. But attaching functions to stdClass is allowed, but one cant call them. Its pure lolphp all the way down.
https://repl.it/repls/SpecializedAngryBrains<|eost|><|sor|>Oof that's a funny one. It looks like you *can* call the function, you just have to be careful not to accidentally use the syntax for invoking a method which takes priority.
https://repl.it/repls/TriflingThunderousBackend
This gives me an idea for another funny lolphp, in which you can call an integer as a function:
https://repl.it/repls/TechnoWellinformedState<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | jesseschalken | ergmavr | <|soss|><|sot|>Calling a method on StdClass always returns FATAL ERROR<|eot|><|sost|>Some sites like [lolphptherightway](https://phptherightway.com/pages/Functional-Programming.html) is trying to spread lies about first class functions. But attaching functions to stdClass is allowed, but one cant call them. Its pure lolphp all the way down.
https://repl.it/repls/SpecializedAngryBrains<|eost|><|sor|>Properties and methods belong to different namespaces, and a different syntax is used for each. Java is the same.
`$foo->bar()` is strictly a method call, not a property access. To call a property as a function you use `($foo->bar)()`.<|eor|><|sor|>Thats a weak excuse. When adding a method dynamically it should be possible to call it like a "normal" class method. This is just PHP design that went down the toilet.<|eor|><|sor|>Why? Methods and properties are fundamentally different concepts. Methods are a part of the class definition and are defined at compile time (script load time in PHP) and called through the class's vtable. Properties are part of the object/class instance itself.
Both Java and C++ distinguish between fields/properties and methods for similar reasons. The only reason you might confuse the two is if you're stuck in a mode of thinking of classes as nothing but fancy hash maps.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | bwmat | errirus | <|soss|><|sot|>Calling a method on StdClass always returns FATAL ERROR<|eot|><|sost|>Some sites like [lolphptherightway](https://phptherightway.com/pages/Functional-Programming.html) is trying to spread lies about first class functions. But attaching functions to stdClass is allowed, but one cant call them. Its pure lolphp all the way down.
https://repl.it/repls/SpecializedAngryBrains<|eost|><|sor|>Properties and methods belong to different namespaces, and a different syntax is used for each. Java is the same.
`$foo->bar()` is strictly a method call, not a property access. To call a property as a function you use `($foo->bar)()`.<|eor|><|sor|>Thats a weak excuse. When adding a method dynamically it should be possible to call it like a "normal" class method. This is just PHP design that went down the toilet.<|eor|><|sor|>Why? Methods and properties are fundamentally different concepts. Methods are a part of the class definition and are defined at compile time (script load time in PHP) and called through the class's vtable. Properties are part of the object/class instance itself.
Both Java and C++ distinguish between fields/properties and methods for similar reasons. The only reason you might confuse the two is if you're stuck in a mode of thinking of classes as nothing but fancy hash maps.<|eor|><|sor|>Actually, in C++ you can do obj.fn_ptr_or_functor(), thanks to good old operator()()<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | TheRagingGeek | 8k4gnq | <|sols|><|sot|>Just everything about this page really.<|eot|><|sol|>http://php.net/manual/en/language.oop5.overloading.php#object.call<|eol|><|eols|><|endoftext|> | 0 |
lolphp | cleeder | dz5becn | <|sols|><|sot|>Just everything about this page really.<|eot|><|sol|>http://php.net/manual/en/language.oop5.overloading.php#object.call<|eol|><|sor|>If you're expecting any upvotes, I'mma need you to go into a bit more detail...<|eor|><|eols|><|endoftext|> | 10 |
lolphp | cleeder | dz5lboj | <|sols|><|sot|>Just everything about this page really.<|eot|><|sol|>http://php.net/manual/en/language.oop5.overloading.php#object.call<|eol|><|sor|>If you're expecting any upvotes, I'mma need you to go into a bit more detail...<|eor|><|soopr|>Magic Methods for the purpose of creating Object Oriented Overloading of functions as opposed to the standard way that other OOP languages handle it (redefining the function with other arguments)<|eoopr|><|sor|>Gotcha. Really, what is presented here is in fact _not_ Overloading at all. That was a poorly chosen term<|eor|><|eols|><|endoftext|> | 8 |
lolphp | __Ephemeral | 25crp1 | <|soss|><|sot|>- Can someone explain "Wello!" to me~?<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 2 |
lolphp | gimbar | chho6nd | <|soss|><|sot|>- Can someone explain "Wello!" to me~?<|eot|><|sost|><|eost|><|sor|>http://w-ll.org/tag/wello/
I searched for some time myself and finally found it!<|eor|><|eoss|><|endoftext|> | 20 |
lolphp | dist | zzuqn | <|soss|><|sot|>Make your brain implode<|eot|><|sost|>
$array1 = array("here","we","go");
$array1[2] = 'go';
$array1[1] = 'we';
$array1[0] = 'here';
$array2 = array('here');
$array2[2] = 'go';
$array2[1] = 'we';
$array2[0] = 'here';
$str1 = implode(',',$array1);
$str2 = implode(',',$array2);
**Without running the code** anywhere, what are the contents of $str1 and $str2?
<|eost|><|eoss|><|endoftext|> | 3 |
lolphp | muddylemon | c6980a2 | <|soss|><|sot|>Make your brain implode<|eot|><|sost|>
$array1 = array("here","we","go");
$array1[2] = 'go';
$array1[1] = 'we';
$array1[0] = 'here';
$array2 = array('here');
$array2[2] = 'go';
$array2[1] = 'we';
$array2[0] = 'here';
$str1 = implode(',',$array1);
$str2 = implode(',',$array2);
**Without running the code** anywhere, what are the contents of $str1 and $str2?
<|eost|><|sor|>Well, if you don't run the code, they'll remain unset and null. <|eor|><|eoss|><|endoftext|> | 35 |
lolphp | huf | c6c5trt | <|soss|><|sot|>Make your brain implode<|eot|><|sost|>
$array1 = array("here","we","go");
$array1[2] = 'go';
$array1[1] = 'we';
$array1[0] = 'here';
$array2 = array('here');
$array2[2] = 'go';
$array2[1] = 'we';
$array2[0] = 'here';
$str1 = implode(',',$array1);
$str2 = implode(',',$array2);
**Without running the code** anywhere, what are the contents of $str1 and $str2?
<|eost|><|sor|>Doesn't really belong in lolphp IMO.
I agree the results are a little unexpected, but only initially.
Arrays are more like a hashtable, Nowhere does PHP claim to order arrays by their numeric index<|eor|><|sor|>Why call them arrays then?<|eor|><|sor|>because they're idiots. i propose the arrayhashkillmenow datastructure they have be called "gonorrhea".<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | robin-gvx | c6bwd9b | <|soss|><|sot|>Make your brain implode<|eot|><|sost|>
$array1 = array("here","we","go");
$array1[2] = 'go';
$array1[1] = 'we';
$array1[0] = 'here';
$array2 = array('here');
$array2[2] = 'go';
$array2[1] = 'we';
$array2[0] = 'here';
$str1 = implode(',',$array1);
$str2 = implode(',',$array2);
**Without running the code** anywhere, what are the contents of $str1 and $str2?
<|eost|><|sor|>Doesn't really belong in lolphp IMO.
I agree the results are a little unexpected, but only initially.
Arrays are more like a hashtable, Nowhere does PHP claim to order arrays by their numeric index<|eor|><|sor|>Why call them arrays then?<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | fieryscribe | re035 | <|sols|><|sot|>PHP 5.4.0 built-in web server DoS PoC<|eot|><|sol|>http://www.exploit-db.com/exploits/18665/<|eol|><|eols|><|endoftext|> | 1 |
lolphp | catcradle5 | oht0r | <|sols|><|sot|>PHP 5.3.8 NULL pointer bugs (DoS vulns)<|eot|><|sol|>http://www.exploit-db.com/exploits/18370<|eol|><|eols|><|endoftext|> | 1 |
lolphp | huf | n6oqk | <|soss|><|sot|>php -r 'var_dump(count(false));'<|eot|><|sost|>jesus. fuck.<|eost|><|eoss|><|endoftext|> | 1 |
lolphp | timtamboy63 | kqt41 | <|sols|><|sot|>Yay for PHP 4 backwards compatibility! (xpost)<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/kqk5e/func_get_args_in_a_class_returns_the_class/<|eol|><|eols|><|endoftext|> | 1 |
lolphp | realnowhereman | hp2jx | <|sols|><|sot|>Short syntax for arrays (rejected RFC)<|eot|><|sol|>https://wiki.php.net/rfc/shortsyntaxforarrays<|eol|><|eols|><|endoftext|> | 1 |
lolphp | ealf | d6c0e | <|soss|><|sot|>if(rand()) global $x;<|eot|><|sost|>global is a statement<|eost|><|eoss|><|endoftext|> | 1 |
lolphp | ealf | cjz4j | <|soss|><|sot|>foreach(array(1,2,3,4) as $x) { switch($x) { case 3: continue; } echo $x; }<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 1 |
lolphp | ealf | cgk3d | <|soss|><|sot|>0 == 'Ffff!'<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 1 |
lolphp | ealf | cat50 | <|soss|><|sot|>$foo='hello'; if (isset($foo['bar'])) { ... }<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 1 |
lolphp | Takeoded | l6lqa4 | <|sols|><|sot|>can somebody explain why the hell shell_exec() doesn't have an `int &$return_code = null` ?<|eot|><|sol|>https://www.php.net/manual/en/function.shell-exec.php<|eol|><|eols|><|endoftext|> | 0 |
lolphp | duskwuff | gl1nwau | <|sols|><|sot|>can somebody explain why the hell shell_exec() doesn't have an `int &$return_code = null` ?<|eot|><|sol|>https://www.php.net/manual/en/function.shell-exec.php<|eol|><|sor|>Because `proc_open()` exists for more complex use cases?<|eor|><|sor|>Even exec() can give a return code. Using the wrong function is the main issue hete
Edit: here<|eor|><|sor|>TBH, part of the problem is simply that PHP has too many different functions to run external commands:
* `shell_exec()` (returns output, no error code)
* `exec()` (returns last line of output, full output and error code in by-ref args)
* `passthru()` (prints output, returns nothing, error code in by-ref arg)
* `system()` (prints output, returns last line of output, error code in by-ref arg)
* `popen()` (interactive, returns file handle)
* `proc_open()` (interactive, multiple file handles in by-ref args)
and probably a few more I forgot about.<|eor|><|eols|><|endoftext|> | 19 |
lolphp | admin_rico | gl1jfr6 | <|sols|><|sot|>can somebody explain why the hell shell_exec() doesn't have an `int &$return_code = null` ?<|eot|><|sol|>https://www.php.net/manual/en/function.shell-exec.php<|eol|><|sor|>Because `proc_open()` exists for more complex use cases?<|eor|><|sor|>Even exec() can give a return code. Using the wrong function is the main issue hete
Edit: here<|eor|><|eols|><|endoftext|> | 11 |
lolphp | admin_rico | gl1jaa6 | <|sols|><|sot|>can somebody explain why the hell shell_exec() doesn't have an `int &$return_code = null` ?<|eot|><|sol|>https://www.php.net/manual/en/function.shell-exec.php<|eol|><|sor|>shell_exec Execute command via shell and return the complete output as a string
Everything after and return is why<|eor|><|soopr|>> the complete output as a string
that ain't it, the return code is never included in the string anyway.
```sh
hans@xDevAd:~$ php -r 'var_dump(shell_exec("php -r '\''echo 123;die(5);'\''"));'
Command line code:1:
string(3) "123"
hans@xDevAd:~$ php -r 'echo 123;die(5);'
123hans@xDevAd:~$ echo $?
5
```<|eoopr|><|sor|>No I mean thats not the function to use if you want a return code.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | duskwuff | gl1j1z7 | <|sols|><|sot|>can somebody explain why the hell shell_exec() doesn't have an `int &$return_code = null` ?<|eot|><|sol|>https://www.php.net/manual/en/function.shell-exec.php<|eol|><|sor|>Because `proc_open()` exists for more complex use cases?<|eor|><|eols|><|endoftext|> | 8 |
lolphp | admin_rico | gl1gdkq | <|sols|><|sot|>can somebody explain why the hell shell_exec() doesn't have an `int &$return_code = null` ?<|eot|><|sol|>https://www.php.net/manual/en/function.shell-exec.php<|eol|><|sor|>shell_exec Execute command via shell and return the complete output as a string
Everything after and return is why<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Takeoded | gl2u9py | <|sols|><|sot|>can somebody explain why the hell shell_exec() doesn't have an `int &$return_code = null` ?<|eot|><|sol|>https://www.php.net/manual/en/function.shell-exec.php<|eol|><|sor|>Because `proc_open()` exists for more complex use cases?<|eor|><|sor|>Even exec() can give a return code. Using the wrong function is the main issue hete
Edit: here<|eor|><|soopr|>upon testing, turns out that exec() is horrible, don't use it anywhere data corruption is unwanted..
exec() trims trailing newlines, if you're using exec() on a program that returns binary data, seems it's pretty much impossible to know if your binary data had "\n" bytes at the end that exec() trimmed away or not <.<<|eoopr|><|eols|><|endoftext|> | 5 |
lolphp | ennorehling | 63yq6d | <|soss|><|sot|>Beware of PHP7 left-to-right parsing<|eot|><|sost|>Today I learned that PHP 7 now uses an abstract syntax tree when parsing source files, and that the framework we use has a bug that's caused by code that boils down to the following.
<?php
function lolphp($foo, $bar) {
return $foo->$bar['foo'];
}
var_dump(lolphp(
(object)array('foo' => 'one', 'bar' => 'two', 'Array' => 'four'),
array('foo' => 'bar')
));
This of course prints either "two" or "f", depending on your PHP version.
<|eost|><|eoss|><|endoftext|> | 0 |
lolphp | belst | dfy29z8 | <|soss|><|sot|>Beware of PHP7 left-to-right parsing<|eot|><|sost|>Today I learned that PHP 7 now uses an abstract syntax tree when parsing source files, and that the framework we use has a bug that's caused by code that boils down to the following.
<?php
function lolphp($foo, $bar) {
return $foo->$bar['foo'];
}
var_dump(lolphp(
(object)array('foo' => 'one', 'bar' => 'two', 'Array' => 'four'),
array('foo' => 'bar')
));
This of course prints either "two" or "f", depending on your PHP version.
<|eost|><|sor|>well thats because u should actually write it like this:
return $foo->{$bar['foo']};
This is even documented as a breaking change when u upgrade to php 7
So no lol here imo (other than ur solution working anywhere in the first place)<|eor|><|eoss|><|endoftext|> | 19 |
lolphp | jesseschalken | dfycbs8 | <|soss|><|sot|>Beware of PHP7 left-to-right parsing<|eot|><|sost|>Today I learned that PHP 7 now uses an abstract syntax tree when parsing source files, and that the framework we use has a bug that's caused by code that boils down to the following.
<?php
function lolphp($foo, $bar) {
return $foo->$bar['foo'];
}
var_dump(lolphp(
(object)array('foo' => 'one', 'bar' => 'two', 'Array' => 'four'),
array('foo' => 'bar')
));
This of course prints either "two" or "f", depending on your PHP version.
<|eost|><|sor|>https://wiki.php.net/rfc/uniform_variable_syntax
The fact that it took so long to fix this is the real lolphp.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | smileytechguy | 4l22nk | <|sols|><|sot|>PDO showing full expanded initializer on error (constants used, default php.ini)<|eot|><|sol|>http://imgur.com/a/PI0Cc<|eol|><|eols|><|endoftext|> | 1 |
lolphp | ajmarks | 1q4e10 | <|sols|><|sot|>I found a case where PHP won't coerce<|eot|><|sol|>https://eval.in/62820<|eol|><|eols|><|endoftext|> | 0 |
lolphp | Sarcastinator | 1q0vsw | <|sols|><|sot|>Low hanging fruit: PHP datatype precision is determined by the platform.<|eot|><|sol|>http://us2.php.net/manual/en/language.types.integer.php<|eol|><|eols|><|endoftext|> | 0 |
lolphp | ajmarks | 1o2876 | <|sols|><|sot|>vBulletin lets just anybody make a new admin account<|eot|><|sol|>http://www.net-security.org/secworld.php?id=15743<|eol|><|eols|><|endoftext|> | 0 |
lolphp | nick_danger | cco5sfn | <|sols|><|sot|>vBulletin lets just anybody make a new admin account<|eot|><|sol|>http://www.net-security.org/secworld.php?id=15743<|eol|><|sor|>So how is this a WTF with PHP? All I see is a system that has a vulnerability that can be exploited, and that some of the attack tools are written in PHP. So? Any clueless moron could do the same thing in just about any toolset. <|eor|><|eols|><|endoftext|> | 11 |
lolphp | InsaneWookie | 1ahnf9 | <|soss|><|sot|>Guess what getting a sub string of an empty string is?<|eot|><|sost|>var_dump(substr("", 0, 1));
> bool(false)
Edit:
What I made completely unclear is that, to me, this should return an empty string (like mb_substr()). Or at least be consistant<|eost|><|eoss|><|endoftext|> | 0 |
lolphp | n1c0_ds | 13m9kd | <|soss|><|sot|>The time-travelling code<|eot|><|sost|>This happened a year ago, so I am typing this from memory.
A while ago, I had a very simple PHP script that, among other things, calculated the interval between to dates. Instead of using ticks, I tried the newfangled DateTime class.
For some reason, one of my calculations, completely unrelated to the date, always came out wrong. Not *just a little wrong*, but *what the fuck is going on* wrong. It sometimes returned random strings when it just performed int operations.
Turns out as soon as DateTime performed a calculation, it corrupted the next variable assignment in the code. If I removed that assignment, it would corrupt the one that was after it. No DateTime, no problems.
I knew PHP wasn't perfect, but that was the exact moment that made me say "so *that*'s what they're talking about!" I used ticks.<|eost|><|eoss|><|endoftext|> | 0 |
lolphp | throwaway-o | pg0x6 | <|soss|><|sot|>T_PAAMAYIM_NEKUDOTAYIM<|eot|><|sost|>Need anyone say more? :-)<|eost|><|eoss|><|endoftext|> | 0 |
lolphp | ealf | m5zq4 | <|sols|><|sot|>Guess what substr('foo', 3) is.<|eot|><|sol|>http://php.net/substr<|eol|><|eols|><|endoftext|> | 0 |
lolphp | ealf | c2yddcu | <|sols|><|sot|>Guess what substr('foo', 3) is.<|eot|><|sol|>http://php.net/substr<|eol|><|soopr|>Off-by-one error in the most basic of string operations? I guess anyone could do that. *Document it as the correct behavior?* That's PHP.<|eoopr|><|eols|><|endoftext|> | 5 |
lolphp | bgeron | c2yhtwk | <|sols|><|sot|>Guess what substr('foo', 3) is.<|eot|><|sol|>http://php.net/substr<|eol|><|sor|>>`<?php var_dump(substr('foo', 3)) ?>` _`bool(false)`_
What's strange about this? Character index 3 doesn't exist, if you count from zero. Also in Python, `'foo'[3:]` = `''`.
<|eor|><|soopr|>Character index 3 doesn't exist, but the range [3,3) is a perfectly valid, empty range. The result should be a zero-length string:
substr('foo...', 0, 3) === 'foo'
substr('foo...', 1, 2) === 'oo'
substr('foo...', 2, 1) === 'o'
substr('foo...', 3, 0) === ''
substr('foo', 0, 3) === 'foo'
substr('foo', 1, 2) === 'oo'
substr('foo', 2, 1) === 'o'
substr('foo', 3, 0) === FALSE, wtf?!
> Also in Python, 'foo'[3:] = ''
Exactly.<|eoopr|><|sor|>That's not an off-by-one error, it's a special case that's not necessary. And it's stupid, I agree.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | throwaway-o | j32h7 | <|sols|><|sot|>I wonder what kind of software would make people behave as pointed out here... (*chuckle*)<|eot|><|sol|>http://lwn.net/Articles/452278/<|eol|><|eols|><|endoftext|> | 0 |
lolphp | ealf | g2woz | <|soss|><|sot|>curl_setopt(CURLOPT_POSTFIELDS, array('message' => $m)) reads a file from the local file system if $m starts with '@'<|eot|><|sost|>Use http_build_query if you want the sane behavior.
EDIT: oh wow, http_build_query takes a 'separator' argument so you can pass '&' as the separator. I am not able rightly to apprehend the kind of confusion of ideas, etc...<|eost|><|eoss|><|endoftext|> | 0 |
lolphp | ealf | dymah | <|soss|><|sot|>list($x[0],$x[2],$x[1])=array('A','B','C'); echo join(",", $x); // try it<|eot|><|sost|><|eost|><|eoss|><|endoftext|> | 0 |
lolphp | sproingie | dngi0q | <|soss|><|sot|>PSR-11 Container Interface<|eot|><|sost|>So I find out that PHP has a common specification for Dependency Injection, namely [PSR-11](https://www.php-fig.org/psr/psr-11/). Cool, that means various DI implementations can interoperate, so a bespoke framework could swap containers like PHP-DI, Symfony, or Laravel. So there'll be specifications for different kinds of wiring, lifecycles, scopes, constructor injection, setter injection, custom factories via closures... Not every container would need implement all these of course, but those parts they do would have a common interface. Nice.
Then I come to the interface. This is the entirety of the PSR-11 container interface specification, minus the comments:
```php
interface ContainerInterface
{
public function get($id);
public function has($id);
}
```
Plus a couple custom exceptions. Nothing else. The meta-document for the PSR even explicitly states that configuring the container is a non-goal, out of scope for the PSR.
Suuuuper useful, this spec.<|eost|><|eoss|><|endoftext|> | 0 |
lolphp | SaltineAmerican_1970 | f5bdhy9 | <|soss|><|sot|>PSR-11 Container Interface<|eot|><|sost|>So I find out that PHP has a common specification for Dependency Injection, namely [PSR-11](https://www.php-fig.org/psr/psr-11/). Cool, that means various DI implementations can interoperate, so a bespoke framework could swap containers like PHP-DI, Symfony, or Laravel. So there'll be specifications for different kinds of wiring, lifecycles, scopes, constructor injection, setter injection, custom factories via closures... Not every container would need implement all these of course, but those parts they do would have a common interface. Nice.
Then I come to the interface. This is the entirety of the PSR-11 container interface specification, minus the comments:
```php
interface ContainerInterface
{
public function get($id);
public function has($id);
}
```
Plus a couple custom exceptions. Nothing else. The meta-document for the PSR even explicitly states that configuring the container is a non-goal, out of scope for the PSR.
Suuuuper useful, this spec.<|eost|><|sor|>Isn't that the point of an interface? Make sure that all extensions have the same functions?
It standardizes "get()" "fetch()" "find()" and "make()" into the same function name. It standardizes "exists()" "has()" "isThere()" and "canGet()' into the same function so laravel's container can be swapped with FireDI's container because you already know to use `get()` and `has()` without changing your code.<|eor|><|eoss|><|endoftext|> | 15 |
lolphp | TinStingray | f5d0qza | <|soss|><|sot|>PSR-11 Container Interface<|eot|><|sost|>So I find out that PHP has a common specification for Dependency Injection, namely [PSR-11](https://www.php-fig.org/psr/psr-11/). Cool, that means various DI implementations can interoperate, so a bespoke framework could swap containers like PHP-DI, Symfony, or Laravel. So there'll be specifications for different kinds of wiring, lifecycles, scopes, constructor injection, setter injection, custom factories via closures... Not every container would need implement all these of course, but those parts they do would have a common interface. Nice.
Then I come to the interface. This is the entirety of the PSR-11 container interface specification, minus the comments:
```php
interface ContainerInterface
{
public function get($id);
public function has($id);
}
```
Plus a couple custom exceptions. Nothing else. The meta-document for the PSR even explicitly states that configuring the container is a non-goal, out of scope for the PSR.
Suuuuper useful, this spec.<|eost|><|sor|>Here's a good example of LOLOP.<|eor|><|eoss|><|endoftext|> | 15 |
lolphp | kokx | f5br9ks | <|soss|><|sot|>PSR-11 Container Interface<|eot|><|sost|>So I find out that PHP has a common specification for Dependency Injection, namely [PSR-11](https://www.php-fig.org/psr/psr-11/). Cool, that means various DI implementations can interoperate, so a bespoke framework could swap containers like PHP-DI, Symfony, or Laravel. So there'll be specifications for different kinds of wiring, lifecycles, scopes, constructor injection, setter injection, custom factories via closures... Not every container would need implement all these of course, but those parts they do would have a common interface. Nice.
Then I come to the interface. This is the entirety of the PSR-11 container interface specification, minus the comments:
```php
interface ContainerInterface
{
public function get($id);
public function has($id);
}
```
Plus a couple custom exceptions. Nothing else. The meta-document for the PSR even explicitly states that configuring the container is a non-goal, out of scope for the PSR.
Suuuuper useful, this spec.<|eost|><|sor|>The entire intention here is to be able to type hint against the PSR-11 Interface. So if your code type hints against it, you can supply any standards conforming container. So you can easily change PHP-DI for Aura.DI for example.
Note that the interface is simple, so all DI implementations can easily implement it. If it specified things like configuration, a lot of DI implementations would not want to conform to the standard.
Why would this need to be more complex? I'd rather it be simple and ubiquitous so you can actually count on it being implemented correctly. Rather than complicated and having several semi conforming containers. Because that is how you get a mess like USB-C.<|eor|><|eoss|><|endoftext|> | 11 |
lolphp | feketegy | cofcx2 | <|sols|><|sot|>Making the language dynamically and strictly typed at the same time. Its a proposal for now.<|eot|><|sol|>https://wiki.php.net/pplusplus/faq<|eol|><|eols|><|endoftext|> | 0 |
lolphp | Takeoded | 9xyhlj | <|sols|><|sot|>C's strlen() ftw<|eot|><|sol|>http://php.net/manual/en/sqlite3.escapestring.php<|eol|><|eols|><|endoftext|> | 0 |
lolphp | ezylot | e9wxl7m | <|sols|><|sot|>C's strlen() ftw<|eot|><|sol|>http://php.net/manual/en/sqlite3.escapestring.php<|eol|><|sor|>Okay....what am I missing?<|eor|><|soopr|>> Warning
This function is not (yet) binary safe!
>>To properly handle BLOB fields which may contain NUL characters, use SQLite3Stmt::bindParam() instead.
<|eoopr|><|sor|>And... what is the connection to strlen of C?<|eor|><|eols|><|endoftext|> | 19 |
lolphp | cleeder | e9wkznt | <|sols|><|sot|>C's strlen() ftw<|eot|><|sol|>http://php.net/manual/en/sqlite3.escapestring.php<|eol|><|sor|>Okay....what am I missing?<|eor|><|eols|><|endoftext|> | 14 |