subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
Matt3k
ef7i4ng
<|sols|><|sot|>The fuckery that is $http_response_header<|eot|><|sol|>https://twitter.com/asgrim/status/1089117795957256193<|eol|><|sor|>...what?<|eor|><|sor|>- Variables magically created in the local scope, rather than supplied as a function result. - Three undocumented gotchas mentioned in the first handful of user comments <|eor|><|eols|><|endoftext|>
13
lolphp
teizhen
ef7crd5
<|sols|><|sot|>The fuckery that is $http_response_header<|eot|><|sol|>https://twitter.com/asgrim/status/1089117795957256193<|eol|><|sor|>...what?<|eor|><|sor|>Someone promoting their unfunny Twatter.<|eor|><|eols|><|endoftext|>
5
lolphp
c_o_r_b_a
ef7qc69
<|sols|><|sot|>The fuckery that is $http_response_header<|eot|><|sol|>https://twitter.com/asgrim/status/1089117795957256193<|eol|><|sor|>...what?<|eor|><|sor|>- Variables magically created in the local scope, rather than supplied as a function result. - Three undocumented gotchas mentioned in the first handful of user comments <|eor|><|sor|>Yup, that's PHP.<|eor|><|eols|><|endoftext|>
5
lolphp
RainOnYourTirade
65glxm
<|soss|><|sot|>Trying to override a standard class? Good luck with default parameters.<|eot|><|sost|>I recently made a class that extends the PDO database class, with support for custom prefixed tables. I ran into this wonderful chain of PHP warnings along the way: public function prepare($statement, array $driver_options = array()) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } What's this? Apparently the default $driver_options isn't supposed to be an array. PHP Warning: Declaration of Database::prepare($statement, array $driver_options = Array) should be compatible with PDO::prepare($statement, $options = NULL) Weird that it wants NULL. The docs clearly show it should take an array: public PDOStatement PDO::prepare ( string $statement [, array $driver_options = array() ] ) But hey, maybe it wants me to have the default as NULL. public function prepare($statement, array $driver_options = NULL) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } Nope, apparently that's wrong too. PHP Warning: Declaration of Database::prepare($statement, array $driver_options = NULL) should be compatible with PDO::prepare($statement, $options = NULL) Maybe if I don't type-hint that the options are supposed to be an array, but it feels weird passing NULL into an array parameter. public function prepare($statement, $driver_options = NULL) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } So is this what it wants? Of course not. PHP Warning: PDO::prepare() expects parameter 2 to be array, null given PHP Fatal error: Uncaught Error: Call to a member function bindValue() on boolean No, that actually fails to construct the PDO. The only way to get it working is like this: public function prepare($statement, $driver_options = NULL) { //If I do anything else it will warn or crash if ($driver_options === NULL) { $driver_options = []; } foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } So gross, so PHP. <|eost|><|eoss|><|endoftext|>
12
lolphp
jesseschalken
dgadjc0
<|soss|><|sot|>Trying to override a standard class? Good luck with default parameters.<|eot|><|sost|>I recently made a class that extends the PDO database class, with support for custom prefixed tables. I ran into this wonderful chain of PHP warnings along the way: public function prepare($statement, array $driver_options = array()) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } What's this? Apparently the default $driver_options isn't supposed to be an array. PHP Warning: Declaration of Database::prepare($statement, array $driver_options = Array) should be compatible with PDO::prepare($statement, $options = NULL) Weird that it wants NULL. The docs clearly show it should take an array: public PDOStatement PDO::prepare ( string $statement [, array $driver_options = array() ] ) But hey, maybe it wants me to have the default as NULL. public function prepare($statement, array $driver_options = NULL) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } Nope, apparently that's wrong too. PHP Warning: Declaration of Database::prepare($statement, array $driver_options = NULL) should be compatible with PDO::prepare($statement, $options = NULL) Maybe if I don't type-hint that the options are supposed to be an array, but it feels weird passing NULL into an array parameter. public function prepare($statement, $driver_options = NULL) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } So is this what it wants? Of course not. PHP Warning: PDO::prepare() expects parameter 2 to be array, null given PHP Fatal error: Uncaught Error: Call to a member function bindValue() on boolean No, that actually fails to construct the PDO. The only way to get it working is like this: public function prepare($statement, $driver_options = NULL) { //If I do anything else it will warn or crash if ($driver_options === NULL) { $driver_options = []; } foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } So gross, so PHP. <|eost|><|sor|>This works fine: class Database extends \PDO { public function prepare($statement, $driver_options = array()) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } } The error was about the type hint. `PDO::prepare()` isn't declared with type hints, so they effectively take `mixed`, so you have to be prepared to accept `mixed` as well. The method signatures in the docs are unrelated to the method signatures used in class hierarchy checks.<|eor|><|eoss|><|endoftext|>
15
lolphp
jesseschalken
dgaes8u
<|soss|><|sot|>Trying to override a standard class? Good luck with default parameters.<|eot|><|sost|>I recently made a class that extends the PDO database class, with support for custom prefixed tables. I ran into this wonderful chain of PHP warnings along the way: public function prepare($statement, array $driver_options = array()) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } What's this? Apparently the default $driver_options isn't supposed to be an array. PHP Warning: Declaration of Database::prepare($statement, array $driver_options = Array) should be compatible with PDO::prepare($statement, $options = NULL) Weird that it wants NULL. The docs clearly show it should take an array: public PDOStatement PDO::prepare ( string $statement [, array $driver_options = array() ] ) But hey, maybe it wants me to have the default as NULL. public function prepare($statement, array $driver_options = NULL) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } Nope, apparently that's wrong too. PHP Warning: Declaration of Database::prepare($statement, array $driver_options = NULL) should be compatible with PDO::prepare($statement, $options = NULL) Maybe if I don't type-hint that the options are supposed to be an array, but it feels weird passing NULL into an array parameter. public function prepare($statement, $driver_options = NULL) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } So is this what it wants? Of course not. PHP Warning: PDO::prepare() expects parameter 2 to be array, null given PHP Fatal error: Uncaught Error: Call to a member function bindValue() on boolean No, that actually fails to construct the PDO. The only way to get it working is like this: public function prepare($statement, $driver_options = NULL) { //If I do anything else it will warn or crash if ($driver_options === NULL) { $driver_options = []; } foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } So gross, so PHP. <|eost|><|sor|>This works fine: class Database extends \PDO { public function prepare($statement, $driver_options = array()) { foreach ($this->tablePrefixes as $prefix => $replacement) { $statement = str_replace($prefix, $replacement, $statement); } return parent::prepare($statement, $driver_options); } } The error was about the type hint. `PDO::prepare()` isn't declared with type hints, so they effectively take `mixed`, so you have to be prepared to accept `mixed` as well. The method signatures in the docs are unrelated to the method signatures used in class hierarchy checks.<|eor|><|soopr|>So it does. Must have been getting tripped up by the docs having a type hint and PhpStorm throwing warnings without the type-hint.<|eoopr|><|sor|>Also, doing string replacement on arbitrary SQL like that can be pretty flaky. You have to watch out for `$prefix` occurring in string literals, in keywords and function names, in column names, in the middle of table names, and even inside the replacement of a previously replaced prefix.<|eor|><|eoss|><|endoftext|>
8
lolphp
ealf
57a2ea
<|sols|><|sot|>DOMDocument assumes the first element it sees is the document element and quietly stuffs all other content inside that.<|eot|><|sol|>https://3v4l.org/kG4sj<|eol|><|eols|><|endoftext|>
12
lolphp
the_alias_of_andrea
d8qlvih
<|sols|><|sot|>DOMDocument assumes the first element it sees is the document element and quietly stuffs all other content inside that.<|eot|><|sol|>https://3v4l.org/kG4sj<|eol|><|sor|>Hmm, is that strictly incorrect behaviour? It is using `LIBXML_HTML_NOIMPLIED`, after all. If it *is* incorrect, given it's using libxml ([I checked](https://github.com/php/php-src/blob/46eea4e41579cff2091e4e60e29cec4c000eac4a/ext/dom/document.c#L2027)), wouldn't the problem not be with PHP per se?<|eor|><|soopr|>You're right, it's just a documentation issue. Where it says > Sets HTML_PARSE_NOIMPLIED flag, which turns off the automatic adding of implied html/body... elements. it should really say > Sets HTML_PARSE_NOIMPLIED flag, which moves arbitrary content inside script tags, because if you wanted an actual HTML parser and not a half-broken XML parser with "HTML" drawn on in crayon, you wouldn't be using PHP. <|eoopr|><|sor|>My guess is a DOM document needs a root element, so if it can't imply HTML tags, it has to use the first element.<|eor|><|sor|>Most other "loose" HTML parsers create an <html> element as the root.<|eor|><|sor|>Right, but here a flag has been used to disable that.<|eor|><|eols|><|endoftext|>
14
lolphp
the_alias_of_andrea
d8qgyvh
<|sols|><|sot|>DOMDocument assumes the first element it sees is the document element and quietly stuffs all other content inside that.<|eot|><|sol|>https://3v4l.org/kG4sj<|eol|><|sor|>Hmm, is that strictly incorrect behaviour? It is using `LIBXML_HTML_NOIMPLIED`, after all. If it *is* incorrect, given it's using libxml ([I checked](https://github.com/php/php-src/blob/46eea4e41579cff2091e4e60e29cec4c000eac4a/ext/dom/document.c#L2027)), wouldn't the problem not be with PHP per se?<|eor|><|soopr|>You're right, it's just a documentation issue. Where it says > Sets HTML_PARSE_NOIMPLIED flag, which turns off the automatic adding of implied html/body... elements. it should really say > Sets HTML_PARSE_NOIMPLIED flag, which moves arbitrary content inside script tags, because if you wanted an actual HTML parser and not a half-broken XML parser with "HTML" drawn on in crayon, you wouldn't be using PHP. <|eoopr|><|sor|>My guess is a DOM document needs a root element, so if it can't imply HTML tags, it has to use the first element.<|eor|><|eols|><|endoftext|>
13
lolphp
the_alias_of_andrea
d8q786p
<|sols|><|sot|>DOMDocument assumes the first element it sees is the document element and quietly stuffs all other content inside that.<|eot|><|sol|>https://3v4l.org/kG4sj<|eol|><|sor|>Hmm, is that strictly incorrect behaviour? It is using `LIBXML_HTML_NOIMPLIED`, after all. If it *is* incorrect, given it's using libxml ([I checked](https://github.com/php/php-src/blob/46eea4e41579cff2091e4e60e29cec4c000eac4a/ext/dom/document.c#L2027)), wouldn't the problem not be with PHP per se?<|eor|><|eols|><|endoftext|>
9
lolphp
Analemma_
4fuqn9
<|sols|><|sot|>33,000 government logins dumped, because someone copy-pasted from PHP's docs<|eot|><|sol|>https://news.ycombinator.com/item?id=11544323<|eol|><|eols|><|endoftext|>
14
lolphp
BilgeXA
d2ca0tw
<|sols|><|sot|>33,000 government logins dumped, because someone copy-pasted from PHP's docs<|eot|><|sol|>https://news.ycombinator.com/item?id=11544323<|eol|><|sor|>That link has nothing to do with 33,000 government logins being dumped.<|eor|><|eols|><|endoftext|>
19
lolphp
DoctorWaluigiTime
d2c61u2
<|sols|><|sot|>33,000 government logins dumped, because someone copy-pasted from PHP's docs<|eot|><|sol|>https://news.ycombinator.com/item?id=11544323<|eol|><|sor|>Less of PHP's fault, more bad programmer's fault. Regardless of language, you shouldn't use online copy/paste examples in your security...<|eor|><|eols|><|endoftext|>
16
lolphp
startwearinggreen
d2e2fpu
<|sols|><|sot|>33,000 government logins dumped, because someone copy-pasted from PHP's docs<|eot|><|sol|>https://news.ycombinator.com/item?id=11544323<|eol|><|sor|>Less of PHP's fault, more bad programmer's fault. Regardless of language, you shouldn't use online copy/paste examples in your security...<|eor|><|sor|>This bug is literally due to someone copy pasting from the official documentation. The official documentation does say "don't do this" but provides a sample of code that does exactly this. While people should not copy random bits of code from the internet, especially when it comes to security, it's unrealistic to expect people to understand the ins and outs of crypto APIs. As such, as the API author, one has a duty to provide idiot-proof documentation. PHP documentation editors clearly didn't take that time. This being said, this isn't endemic to php. Lots of languages and libs do the same. It's a shame, really. You design a full, tested, secure crypto lib, you make the API usable securely... And you ruin it all by providing a dangerous snippet as your main example.<|eor|><|eols|><|endoftext|>
7
lolphp
Takeoded
d2ckbjl
<|sols|><|sot|>33,000 government logins dumped, because someone copy-pasted from PHP's docs<|eot|><|sol|>https://news.ycombinator.com/item?id=11544323<|eol|><|sor|>That link has nothing to do with 33,000 government logins being dumped.<|eor|><|sor|>no, but it got him the likes, didn't it? :p<|eor|><|eols|><|endoftext|>
5
lolphp
the_alias_of_andrea
447mg3
<|sols|><|sot|>PHPWTF<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/445of9/phpwtf/<|eol|><|eols|><|endoftext|>
12
lolphp
andsens
43olfi
<|sols|><|sot|>DateInterval::__construct Creates a new DateInterval object -- The format starts with the letter P, for "period."<|eot|><|sol|>http://fi2.php.net/manual/en/dateinterval.construct.php<|eol|><|eols|><|endoftext|>
11
lolphp
andsens
czjp3p6
<|sols|><|sot|>DateInterval::__construct Creates a new DateInterval object -- The format starts with the letter P, for "period."<|eot|><|sol|>http://fi2.php.net/manual/en/dateinterval.construct.php<|eol|><|soopr|>I think I have to backpedal on this one. The fault doesn't seem to be with PHP but rather the way the ISO standard uses the terms: * Duration * Interval * Period To me, the first two can be used interchangeably while a period has a fixed start and end. Reading the standard, it seems they didn't bother with defining those unimportant details upfront, so it's really no wonder that a random spec results in a random implementation.<|eoopr|><|eols|><|endoftext|>
19
lolphp
pilif
czjuomx
<|sols|><|sot|>DateInterval::__construct Creates a new DateInterval object -- The format starts with the letter P, for "period."<|eot|><|sol|>http://fi2.php.net/manual/en/dateinterval.construct.php<|eol|><|sor|>The constructor actually uses the ISO specified format. I would recommend to use the much more user-friendly [DateInterval::createFromDateString](http://www.php.net/manual/en/dateinterval.createfromdatestring.php) method. I agree that the ISO specification is kind of a WTF, but on the other hand, that format is guaranteed to be non-ambiguous and at least has the chance to be potentially understood by anybody, so I think it's an ok default. Automatically trying to infer what the user wants by trying to parse the string as an ISO interval and then falling back to heuristics is IMHO asking for trouble in a default constructor method.<|eor|><|eols|><|endoftext|>
12
lolphp
knightry
czjvbjq
<|sols|><|sot|>DateInterval::__construct Creates a new DateInterval object -- The format starts with the letter P, for "period."<|eot|><|sol|>http://fi2.php.net/manual/en/dateinterval.construct.php<|eol|><|soopr|>I think I have to backpedal on this one. The fault doesn't seem to be with PHP but rather the way the ISO standard uses the terms: * Duration * Interval * Period To me, the first two can be used interchangeably while a period has a fixed start and end. Reading the standard, it seems they didn't bother with defining those unimportant details upfront, so it's really no wonder that a random spec results in a random implementation.<|eoopr|><|sor|>Duration and Interval are not synonymous. I suggest reading the joda docs on these classes to get a better explanation than php would provide.<|eor|><|eols|><|endoftext|>
10
lolphp
Olathe
czk6ddw
<|sols|><|sot|>DateInterval::__construct Creates a new DateInterval object -- The format starts with the letter P, for "period."<|eot|><|sol|>http://fi2.php.net/manual/en/dateinterval.construct.php<|eol|><|soopr|>I think I have to backpedal on this one. The fault doesn't seem to be with PHP but rather the way the ISO standard uses the terms: * Duration * Interval * Period To me, the first two can be used interchangeably while a period has a fixed start and end. Reading the standard, it seems they didn't bother with defining those unimportant details upfront, so it's really no wonder that a random spec results in a random implementation.<|eoopr|><|sor|>Duration and Interval are not synonymous. I suggest reading the joda docs on these classes to get a better explanation than php would provide.<|eor|><|sor|>There's also [an excellent explanation on Stack Overflow](https://stackoverflow.com/a/2653655).<|eor|><|eols|><|endoftext|>
6
lolphp
allthediamonds
2j3tj0
<|sols|><|sot|>[xpost r/PHP] Can you convince me not to use DreamWeaver?<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/2iub9o/can_you_convince_me_to_not_use_dreamweaver/<|eol|><|eols|><|endoftext|>
10
lolphp
shvelo
cl859vb
<|sols|><|sot|>[xpost r/PHP] Can you convince me not to use DreamWeaver?<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/2iub9o/can_you_convince_me_to_not_use_dreamweaver/<|eol|><|sor|>Dreamweaver isn't the biggest issue here, he/she was using NOTEPAD, fucking notepad. How stupid should you be to use notepad for anything else than viewing a simple txt file.<|eor|><|eols|><|endoftext|>
14
lolphp
h0rst_
cl8iq68
<|sols|><|sot|>[xpost r/PHP] Can you convince me not to use DreamWeaver?<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/2iub9o/can_you_convince_me_to_not_use_dreamweaver/<|eol|><|sor|>Dreamweaver isn't the biggest issue here, he/she was using NOTEPAD, fucking notepad. How stupid should you be to use notepad for anything else than viewing a simple txt file.<|eor|><|sor|>When I jump on other peoples windows machines and I need to edit a code file I use notepad because it's monospaced and doesn't do weird shit with carriage returns. Surprisingly this actually comes up a lot with me...<|eor|><|sor|>> notepad [...] doesn't do weird shit with carriage returns In my memory notepad was unable to display a file with linux linebreaks the way it was supposed to be, and I had to switch to some poor mans wysiwyg-editor that came with windows (was it wordpad? don't really remember) to change anything in a file like that. Then again, haven't really touched notepad since the windows xp days, it might be fixed these days.<|eor|><|eols|><|endoftext|>
13
lolphp
hex_m_hell
cl8833l
<|sols|><|sot|>[xpost r/PHP] Can you convince me not to use DreamWeaver?<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/2iub9o/can_you_convince_me_to_not_use_dreamweaver/<|eol|><|sor|>Dreamweaver isn't the biggest issue here, he/she was using NOTEPAD, fucking notepad. How stupid should you be to use notepad for anything else than viewing a simple txt file.<|eor|><|sor|>Real men use ed<|eor|><|sor|>Ed and cat. What else do you need?<|eor|><|eols|><|endoftext|>
7
lolphp
arand
cl8aepf
<|sols|><|sot|>[xpost r/PHP] Can you convince me not to use DreamWeaver?<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/2iub9o/can_you_convince_me_to_not_use_dreamweaver/<|eol|><|sor|>Dreamweaver isn't the biggest issue here, he/she was using NOTEPAD, fucking notepad. How stupid should you be to use notepad for anything else than viewing a simple txt file.<|eor|><|sor|>Real men use ed<|eor|><|sor|>Ed and cat. What else do you need?<|eor|><|sor|>Obligatory butterflies! And emacs has a command for that.<|eor|><|eols|><|endoftext|>
7
lolphp
audaxxx
cl89ure
<|sols|><|sot|>[xpost r/PHP] Can you convince me not to use DreamWeaver?<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/2iub9o/can_you_convince_me_to_not_use_dreamweaver/<|eol|><|sor|>Convince me not to use vim. I've used vim for years and I'm really productive in it and I love how I have my settings configured and everything in it. I have the full Linux suite so I figure I might as well use it. :x<|eor|><|sor|>As a newbie vim user (1-2 years), there's still a lot of things that fundamentally can't work in a cli-based text editor that I miss. Sublime text's minimap, for example. [Ligatures](https://github.com/i-tu/Hasklig), too. gvim isn't enough of a jump in usability for me to want to abandon terminal niceties like tmux. I'd love for a big new mode-based text editor to come into play and replace vim, but I don't think it's happening any time soon.<|eor|><|sor|>Emacs + Evil can do that.<|eor|><|eols|><|endoftext|>
5
lolphp
lolphp
1owwcz
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|eols|><|endoftext|>
12
lolphp
ma-int
ccwodwa
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|soopr|>the actual lolphp is in the codebase itself. it's spaghetti<|eoopr|><|sor|>can you post an example?<|eor|><|sor|>I took a random sample of 2 files and looked at both. Since my eyes are now bleeding I approximate at least 7,5 WTF/min https://github.com/devlab-oy/pupesoft/blob/master/ulask.php<|eor|><|eols|><|endoftext|>
10
lolphp
lolphp
ccwfdse
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|soopr|>the actual lolphp is in the codebase itself. it's spaghetti<|eoopr|><|eols|><|endoftext|>
9
lolphp
bobjohnsonmilw
ccwxawo
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|sor|>I usually am like, ehh, this isn't really that bad. This is pretty bad. Sql mixed in with <font> tags? Wow.<|eor|><|eols|><|endoftext|>
8
lolphp
nikomo
ccwvvxz
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|sor|>As a Finn, this is the most informal Finnish I've seen in a long while. Those commit messages would be fine for a personal thing, but anything that someone else would have to read? Fuck no.<|eor|><|eols|><|endoftext|>
8
lolphp
ajmarks
ccwi3o8
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|sor|>IDGI? Why is this lolphp?<|eor|><|eols|><|endoftext|>
8
lolphp
sopvop
ccwy7cl
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|sor|>Saatana Perkele!<|eor|><|eols|><|endoftext|>
7
lolphp
wwwwolf
ccxr77i
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|sor|>As a Finn, this is the most informal Finnish I've seen in a long while. Those commit messages would be fine for a personal thing, but anything that someone else would have to read? Fuck no.<|eor|><|sor|>The [DB](http://api.devlab.fi/referenssitietokantakuvaus.sql) is pretty hilarious as well, but probably only for Finnish speakers.. <|eor|><|sor|>Some jokes definitely transcend language barriers. > `NOT NULL DEFAULT ''` (and other fantastic default values to avoid dealing with this alien concept known as `NULL`) > > `ENGINE=MyISAM` (totally enterprise-ready shit here) > > `/*!40101 SET character_set_client = utf8 */` > `DEFAULT CHARSET=latin1` > (These guys didn't live through 1990s, the horrible era when none of the character sets ever coincided. We, the survivors, made a solemn pact not to repeat those atrocities.) > > Ctrl+F "foreign key" &rarr; no hits<|eor|><|eols|><|endoftext|>
6
lolphp
ajmarks
ccwiuwl
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|sor|>IDGI? Why is this lolphp?<|eor|><|sor|>Probably because of gazillion lines of code and phpfiles with finnish naming. That much php must hurt you brain.<|eor|><|sor|>lolfinnish?<|eor|><|eols|><|endoftext|>
6
lolphp
Lokaltog
ccwr1wm
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|soopr|>the actual lolphp is in the codebase itself. it's spaghetti<|eoopr|><|sor|>can you post an example?<|eor|><|sor|>I took a random sample of 2 files and looked at both. Since my eyes are now bleeding I approximate at least 7,5 WTF/min https://github.com/devlab-oy/pupesoft/blob/master/ulask.php<|eor|><|sor|>Hahaha, holy shit! That is *the worst* piece of code I've ever read! I don't feel that you can put all the blame on PHP in this case though, this is just absolutely terrible and would probably look like utter shit in any scripting language. Nice find though, got a good laugh from this one!<|eor|><|eols|><|endoftext|>
5
lolphp
demonyte
ccx2bzh
<|sols|><|sot|>pupesoft - A finnish ERP app.<|eot|><|sol|>https://github.com/devlab-oy/pupesoft<|eol|><|soopr|>the actual lolphp is in the codebase itself. it's spaghetti<|eoopr|><|sor|>can you post an example?<|eor|><|sor|>No examples since you can view just about any file there and have a pretty high WTF/min rate. But seriously speaking, it's just lacking any architecture or isolation/abstraction of routines. Models are some variables here and there, views and controllers are mixed together, and html structure is a bunch of echo strings - maybe I was blind but I was unable to find any template files in that repo. SQL queries everywhere, decentralized. Using global variables inside functions (instead of bringing them via parameters) is bad practise. [Repeating routines](https://github.com/devlab-oy/pupesoft/blob/master/ulask.php#L229). You could read the whole codebase as a counter-example to what Steve McConnell tries to tell you in Code Complete. I guess the owners just wanted quick and dirty prototype code that could be sold to its clients before coming back to improve the architecture. The company's revenue was 763 000 in 2011-2012 with diminishing profits at around 11k (with last year's profit at 23k). [1] I'd *really* like to know how a business is able to spend almost 800k with a crew of 10. [1] [Devlab Oy - Taloussanomat](http://yritys.taloussanomat.fi/y/devlab-oy/helsinki/0838105-5/)<|eor|><|sor|>The whole company is a spin-off based around that spaghetti. It was started years ago as a in-house ERP for a car parts importer/supplier and later spun off to it's own company.<|eor|><|eols|><|endoftext|>
5
lolphp
huf
1m19tb
<|sols|><|sot|>A better way to do substr(PHP_VERSION, 0, 1)...<|eot|><|sol|>https://github.com/jonursenbach/smarty-lint/blob/master/smarty-lint#L29<|eol|><|eols|><|endoftext|>
10
lolphp
huf
cc5ehhz
<|sols|><|sot|>A better way to do substr(PHP_VERSION, 0, 1)...<|eot|><|sol|>https://github.com/jonursenbach/smarty-lint/blob/master/smarty-lint#L29<|eol|><|sor|>Not exactly a lolphp<|eor|><|soopr|>no? then explain that line to me. especially why the rightmost occurrence of $version is required.<|eoopr|><|eols|><|endoftext|>
5
lolphp
tdammers
1do59z
<|soss|><|sot|>Ten million dollars<|eot|><|sost|>Enjoy: <?php $a="a\n"; $$a=$a; eval('echo ' . str_repeat('$', 10000000) . 'a;'); I really can't imagine why, but it does work. Takes a while though. <|eost|><|eoss|><|endoftext|>
13
lolphp
nikomo
c9zsit3
<|soss|><|sot|>Ten million dollars<|eot|><|sost|>Enjoy: <?php $a="a\n"; $$a=$a; eval('echo ' . str_repeat('$', 10000000) . 'a;'); I really can't imagine why, but it does work. Takes a while though. <|eost|><|sor|>Well, once you permit variable variables the sky is the limit, and combining with in-quote variables being parsed like regular variables it all boiles down to the same thing. Though the newline makes it a bit confusing on the left hand side of line 3. edit: 5.4.9-4 outputs a single "a". Guess the newline gets stripped of somewhere on the $$a=$a or something. Not really in the mood for thinking ^^<|eor|><|sor|>>Not really in the mood for thinking Congratulations, you've just been hired as a PHP developer. When can you start?<|eor|><|eoss|><|endoftext|>
16
lolphp
tdammers
ca29j2v
<|soss|><|sot|>Ten million dollars<|eot|><|sost|>Enjoy: <?php $a="a\n"; $$a=$a; eval('echo ' . str_repeat('$', 10000000) . 'a;'); I really can't imagine why, but it does work. Takes a while though. <|eost|><|sor|>> str_repeat('$', 10000000) Ugh. Why couldnt the PHP idiots do sane stuff like `'$' * 10000000`?<|eor|><|soopr|>Overloading operators for radically different operations () in a dynamically-typed language is a bad thing IMO, because it makes for subtle gotchas that are hard to spot and cause all sorts of weird bugs. But that's an entirely different story.<|eoopr|><|eoss|><|endoftext|>
11
lolphp
lexyeevee
cag2yl6
<|soss|><|sot|>Ten million dollars<|eot|><|sost|>Enjoy: <?php $a="a\n"; $$a=$a; eval('echo ' . str_repeat('$', 10000000) . 'a;'); I really can't imagine why, but it does work. Takes a while though. <|eost|><|sor|>> str_repeat('$', 10000000) Ugh. Why couldnt the PHP idiots do sane stuff like `'$' * 10000000`?<|eor|><|soopr|>Overloading operators for radically different operations () in a dynamically-typed language is a bad thing IMO, because it makes for subtle gotchas that are hard to spot and cause all sorts of weird bugs. But that's an entirely different story.<|eoopr|><|sor|>I think you meant a *weakly* typed language, not dynamically. Dynamic languages like Python and Ruby allow operator overloading, but since `5 + "5"` is invalid, you generally know when you're doing something wrong. In PHP, since `"5"` can so easily be interpreted as the integer `5`, things would get extremely confusing. They were smart to not overload the addition and concatenation operator, actually. One of the few smart decisions they've made (even if they pretty much just stole it from Perl).<|eor|><|soopr|>No, I really did mean *dynamically* typed. You can still write `5 + "5"` in Python, and it will compile and lint just fine. In order to automatically detect the problem, you have to actually run the code, either manually or through a unit test. And then you have to make sure your unit tests themselves are complete and bug-free, which isn't a trivial task by itself. Sure, there's tools to help you out there, but a statically-typed language avoids 90% of the necessity of such tests in the first place, and the larger your project grows, the less significant the extra effort required to write type-correct code (unless the statically-typed language is Java or something similar). As far as `+` vs. `.` in PHP goes: I think it's pure luck that they got this one half right; `+` is still overloaded for *array* concatenation though, and most of the other operators are overloaded for everything (including the equality comparison, where Perl makes a clear distinction between numeric equality and object equality, i.e. `==` vs. `eq`).<|eoopr|><|sor|>That's a general complaint about dynamic typing and has nothing to do with overloaded operators. Subtraction is only defined for numbers in most dynamic languages, but you still won't know for sure whether `x - y` is valid until it runs.<|eor|><|soopr|>The complaint is not that `x + y` is sometimes invalid. The complaint is that `x + y` in Python does two (or even three) radically different things depending on the types of its operands. I'd rather Python give me the finger for trying to do numeric addition on strings instead of assuming that I want string concatenation instead. And all intuition fails when the operands are of different types: there is no reason why either overload should be favored in the `5 + "5"` case, so intuition has no way of telling you whether the result should be `"55"` or `10` - so I say the least surprising thing to do would be to throw an exception because you tried to do numeric addition on a number and a string.<|eoopr|><|sor|>Python _does_ throw an exception when you try to add a number and a string.<|eor|><|eoss|><|endoftext|>
5
lolphp
OrangeredStilton
vspa8
<|sols|><|sot|>SQLite2 support removed, including session storage; SQLite3 session storage never included<|eot|><|sol|>https://bugs.php.net/bug.php?id=53713<|eol|><|eols|><|endoftext|>
11
lolphp
dipswitch
vbzdw
<|sols|><|sot|>Count the CVEs in todays update<|eot|><|sol|>https://launchpad.net/ubuntu/+source/php5/5.3.10-1ubuntu3.2/+changelog<|eol|><|eols|><|endoftext|>
12
lolphp
ealf
jl7td
<|sols|><|sot|>"hexdec() converts a hexadecimal string to a decimal number"<|eot|><|sol|>http://php.net/hexdec<|eol|><|eols|><|endoftext|>
13
lolphp
i-am-am-nice-really
c2d2w59
<|sols|><|sot|>"hexdec() converts a hexadecimal string to a decimal number"<|eot|><|sol|>http://php.net/hexdec<|eol|><|sor|>pure genius print(hexdec("get fucked php!!")); 982253<|eor|><|eols|><|endoftext|>
8
lolphp
ch0wn
hloz9
<|sols|><|sot|>PHP Sadness<|eot|><|sol|>http://www.phpsadness.com/<|eol|><|eols|><|endoftext|>
11
lolphp
shitcanz
m7l1je
<|soss|><|sot|>PHP when things did not work out as planned<|eot|><|sost|>One of the joys of PHP. Looks like everything needs some sort of hack to work. Its amazing how small things are always so hard. https://phpize.online/?phpses=6f15b18c62823bdcf9e07ac476773a84&sqlses=null&php_version=php8&sql_version=mysql57<|eost|><|eoss|><|endoftext|>
11
lolphp
IluTov
grbxhoj
<|soss|><|sot|>PHP when things did not work out as planned<|eot|><|sost|>One of the joys of PHP. Looks like everything needs some sort of hack to work. Its amazing how small things are always so hard. https://phpize.online/?phpses=6f15b18c62823bdcf9e07ac476773a84&sqlses=null&php_version=php8&sql_version=mysql57<|eost|><|sor|>1. Arrays have been used as closures as a workaround. It's not great but the plan is to allow something like `takesClosure($this->foo(?))` in the future. The reason `takesClosure($this->foo)` doesn't work is that in PHP properties and methods can have the same name. 2. The documentation is wrong here. Needs to be adjusted. Luckily, a lot of effort was put into making the docs available on GitHub recently so that the community can help fixing the docs. https://github.com/php/doc-en 3. Also agree that this behavior is slightly weird. But adjusting it is probably not worth the BC break. 4. No clue what you're trying to say here. 5. I wouldn't say PHP arrays are broken by design but they do try to do too much IMO. Keeping the index is certainly the right behavior a lot of the time. But the behavior would be much more obvious if we had separate array and map data structures.<|eor|><|eoss|><|endoftext|>
10
lolphp
elcapitanoooo
grbz886
<|soss|><|sot|>PHP when things did not work out as planned<|eot|><|sost|>One of the joys of PHP. Looks like everything needs some sort of hack to work. Its amazing how small things are always so hard. https://phpize.online/?phpses=6f15b18c62823bdcf9e07ac476773a84&sqlses=null&php_version=php8&sql_version=mysql57<|eost|><|sor|>PHP arrays are the worst. They are like some mutant collectiony type. The array is one of the base lols the language is heavily based upon. I have seen some people even going as far as banning arrays, and forcing (via code review) a wrapper built ontop of the array. A huge lol indeed. Also one that will never be fixed, the array will be probably be broken forever.<|eor|><|eoss|><|endoftext|>
9
lolphp
squiggleslash
grdsyq7
<|soss|><|sot|>PHP when things did not work out as planned<|eot|><|sost|>One of the joys of PHP. Looks like everything needs some sort of hack to work. Its amazing how small things are always so hard. https://phpize.online/?phpses=6f15b18c62823bdcf9e07ac476773a84&sqlses=null&php_version=php8&sql_version=mysql57<|eost|><|sor|>PHP arrays are the worst. They are like some mutant collectiony type. The array is one of the base lols the language is heavily based upon. I have seen some people even going as far as banning arrays, and forcing (via code review) a wrapper built ontop of the array. A huge lol indeed. Also one that will never be fixed, the array will be probably be broken forever.<|eor|><|sor|>I don't understand why this is so common. I've noticed Lua and Javascript also do the frankenarrayobject thing, and if anything they're worse.at least PHP arrays are always maps, either consecutive numbers or arbitrary strings. JS, on the other hand, is fine with (what in PHP would be written as) $something["x"]=1; echo $something->x; $something["y"] = function() { echo $this->x; }; $something->y();)<|eor|><|eoss|><|endoftext|>
7
lolphp
Takeoded
g8h6jp
<|sols|><|sot|>something seems very wrong with float->int conversion<|eot|><|sol|>https://3v4l.org/PYRPM<|eol|><|eols|><|endoftext|>
12
lolphp
nikic
foo5e98
<|sols|><|sot|>something seems very wrong with float->int conversion<|eot|><|sol|>https://3v4l.org/PYRPM<|eol|><|soopr|>inb4 this is documented behavior: > sometimes floats above 0 but below PHP_INT_MAX when casted to int becomes negative because (blah blah bla) ^^^\/s<|eoopr|><|sor|>But 9223372036854775808 isn't below `PHP_INT_MAX`. `PHP_INT_MAX == 9223372036854775807`, so `(int) 9223372036854775808 == -9223372036854775808` is the expected behavior.<|eor|><|soopr|>> 9223372036854775808 == -9223372036854775808 is the expected behavior. what? why? that is a positive number, why do you expect a *positive* float to get casted to a *negative* int ? for the record, when i do this in c++: std::cout << int64_t(double(9223372036854775808)) << std::endl; i get: hans@xDevAd:~$ ./a.out 9223372036854775807 (also php's float is a C `double`, and 64bit php's int is a C's int64_t - php doesn't have anything like C's float, it only has C's double, and calls that `float`)<|eoopr|><|sor|>Oh boy. Casting a non-representable floating-point number to integer is undefined behavior in C and C++. In practice, you will usually either get back a saturated integer for const-evaluated casts, or INT_MIN, which is the INDVAL on x86 architectures. Of course, if you target a different architecture, you will get different results, e.g. AArch64 uses saturation. For programming languages that do define out-of-range integer casts, the newer ones tend to define them as saturating, while older ones follow the same truncation semantics as PHP does (if I remember correctly, this is the case in JavaScript). Some go for a mix, e.g. Java will saturate for large integer types and truncate for small types. The truncation behavior is rooted in the cast behavior of integers, which is pretty universally accepted to truncate.<|eor|><|eols|><|endoftext|>
22
lolphp
the_alias_of_andrea
fookkyg
<|sols|><|sot|>something seems very wrong with float->int conversion<|eot|><|sol|>https://3v4l.org/PYRPM<|eol|><|sor|>64-bit PHP_INT_MAX is too large to be represented exactly as a float, so it is rounded to the nearest power of two (2^(63)), which is one greater than PHP_INT_MAX. Float to integer casts in PHP do a truncation, which is modulo 2^(64) but it's two's complement (it's not very nice sorry), and since PHP_INT_MAX converted to a float is bigger than PHP_INT_MAX, it wraps around. It's not great, but each approach has its drawbacks for this kind of reason, [I made overflowing float->int conversions result in type errors](https://wiki.php.net/rfc/zpp_fail_on_overflow) for function parameters. But it's my belief that the explicit cast shouldn't throw an error depending on the input value.<|eor|><|eols|><|endoftext|>
14
lolphp
the_alias_of_andrea
fooibh2
<|sols|><|sot|>something seems very wrong with float->int conversion<|eot|><|sol|>https://3v4l.org/PYRPM<|eol|><|soopr|>inb4 this is documented behavior: > sometimes floats above 0 but below PHP_INT_MAX when casted to int becomes negative because (blah blah bla) ^^^\/s<|eoopr|><|sor|>But 9223372036854775808 isn't below `PHP_INT_MAX`. `PHP_INT_MAX == 9223372036854775807`, so `(int) 9223372036854775808 == -9223372036854775808` is the expected behavior.<|eor|><|soopr|>> 9223372036854775808 == -9223372036854775808 is the expected behavior. what? why? that is a positive number, why do you expect a *positive* float to get casted to a *negative* int ? for the record, when i do this in c++: std::cout << int64_t(double(9223372036854775808)) << std::endl; i get: hans@xDevAd:~$ ./a.out 9223372036854775807 (also php's float is a C `double`, and 64bit php's int is a C's int64_t - php doesn't have anything like C's float, it only has C's double, and calls that `float`)<|eoopr|><|sor|>Oh boy. Casting a non-representable floating-point number to integer is undefined behavior in C and C++. In practice, you will usually either get back a saturated integer for const-evaluated casts, or INT_MIN, which is the INDVAL on x86 architectures. Of course, if you target a different architecture, you will get different results, e.g. AArch64 uses saturation. For programming languages that do define out-of-range integer casts, the newer ones tend to define them as saturating, while older ones follow the same truncation semantics as PHP does (if I remember correctly, this is the case in JavaScript). Some go for a mix, e.g. Java will saturate for large integer types and truncate for small types. The truncation behavior is rooted in the cast behavior of integers, which is pretty universally accepted to truncate.<|eor|><|sor|>Yeah. PHP doesn't have the nicest behaviour, but it's _defined_ at least now.<|eor|><|eols|><|endoftext|>
7
lolphp
piechart
fonui5q
<|sols|><|sot|>something seems very wrong with float->int conversion<|eot|><|sol|>https://3v4l.org/PYRPM<|eol|><|sor|>Seems like due to float rounding `18446744073709552000 - PHP_INT_MAX === PHP_INT_MAX + 1` which overflows to `PHP_INT_MIN` when cast to int.<|eor|><|eols|><|endoftext|>
5
lolphp
TortoiseWrath
foo1bi5
<|sols|><|sot|>something seems very wrong with float->int conversion<|eot|><|sol|>https://3v4l.org/PYRPM<|eol|><|soopr|>inb4 this is documented behavior: > sometimes floats above 0 but below PHP_INT_MAX when casted to int becomes negative because (blah blah bla) ^^^\/s<|eoopr|><|sor|>But 9223372036854775808 isn't below `PHP_INT_MAX`. `PHP_INT_MAX == 9223372036854775807`, so `(int) 9223372036854775808 == -9223372036854775808` is the expected behavior.<|eor|><|eols|><|endoftext|>
5
lolphp
chin98edwin
cffh1r
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|eoss|><|endoftext|>
12
lolphp
vita10gy
eu9rdvi
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|sor|>$needle, $haystack make perfect sense as terms, if that's the complaint. The real WTF with those is that it seems like they flipped a coin on every usage of them to determine the order.<|eor|><|eoss|><|endoftext|>
30
lolphp
barubary
euajpsr
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|sor|>http://man7.org/linux/man-pages/man3/strstr.3.html Talking about weird names and jargons: strstr(), strchr(), strrchr(), strpbrk()... I could go on for a while. So I guess, r/lolc? I mean, I don't code PHP, but seeing those names does not make me puke any more than seeing any C code. And I love C and systems programming by heart.<|eor|><|sor|>The C standard library at least has a good reason: C has no namespaces, so global names need a unique prefix, and when C was standardized (in the 1980s), it had to run on some old systems whose linkers only supported 6 significant characters (case insensitive!) in global symbols. In the absence of namespaces it seems reasonable to give string functions a `str` prefix, which leaves only 3 characters for the actual function name. These constraints force names like `string_contains_string` and `string_copy` to be condensed down to `strstr` and `strcpy`, respectively. Sometimes the standard library exceeds its self-imposed limit of 6 characters in a name, e.g. `strpbrk` (which would be exposed as `STRPBR` on those aforementioned platforms). That works fine as long as you don't define another function that also starts with `strpbr`. C99 significantly raised those limits: You can now rely on 31 significant initial characters in a global symbol, and even that limit is only there because of old existing platforms. Otherwise you should be able to use up to 255 characters. All of that comes too late to change the whole standard library, of course.<|eor|><|eoss|><|endoftext|>
17
lolphp
tansly
eua9v7x
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|sor|>http://man7.org/linux/man-pages/man3/strstr.3.html Talking about weird names and jargons: strstr(), strchr(), strrchr(), strpbrk()... I could go on for a while. So I guess, r/lolc? I mean, I don't code PHP, but seeing those names does not make me puke any more than seeing any C code. And I love C and systems programming by heart.<|eor|><|eoss|><|endoftext|>
11
lolphp
newplayerentered
eu9vbe1
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|sor|>Can you suggest better names instead of in_array(), $needle, $haystack?<|eor|><|eoss|><|endoftext|>
8
lolphp
b1ackcat
eu9mapw
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|sor|>Oh just you wait. You're experiencing the tip of the iceberg. Just wait until you get to `call_user_func()`, traits, and the absolute worst language feature you'll ever find: Variable variables. Those three things alone have caused me so much grief that I took the time to write my own .phpcs rules for our linter to auto-deny any new PR that introduces more of them.<|eor|><|eoss|><|endoftext|>
7
lolphp
b1ackcat
euao737
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|sor|>Oh just you wait. You're experiencing the tip of the iceberg. Just wait until you get to `call_user_func()`, traits, and the absolute worst language feature you'll ever find: Variable variables. Those three things alone have caused me so much grief that I took the time to write my own .phpcs rules for our linter to auto-deny any new PR that introduces more of them.<|eor|><|sor|>Whats wrong with traits?<|eor|><|sor|>It's like someone went "how can we implement inheritance, but in the dumbest way possible?" Traits are just an explicit form of shoehorning code into place. Since they're added to a class via a declaration instead of being injected in at runtime, they're impossible to mock, which makes the class impossible to test properly. There's literally no advantage to using them in favor of dependency injection. And you can't new up a trait by itself, so you can't even test them without some bullshit hackery. Not only that, but they can access `this` of the class they're going to be added to, even though the code doesn't know what class it's going to be attached to! That's just ridiculous, because that means you have to design your interactions with the class using things like `call_user_func` and other nefarious constructs. Traits are at best, a poor design choice, and at worst, something that actively hampers testing efforts, all for literally no benefit. I hate traits.<|eor|><|eoss|><|endoftext|>
7
lolphp
the_alias_of_andrea
eu9l6qn
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|sor|>Yes, it's a mess, and this particular aspect hasn't really gotten better and has no good justification. Other, nicer languages do exist that can do everything PHP can, if you want to try those.<|eor|><|eoss|><|endoftext|>
6
lolphp
b1ackcat
eu9tn6h
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|sor|>Oh just you wait. You're experiencing the tip of the iceberg. Just wait until you get to `call_user_func()`, traits, and the absolute worst language feature you'll ever find: Variable variables. Those three things alone have caused me so much grief that I took the time to write my own .phpcs rules for our linter to auto-deny any new PR that introduces more of them.<|eor|><|sor|>How does your project implement composition over inheritance, if not with PHP traits?<|eor|><|sor|>https://tenor.com/view/not-sure-still-joking-joking-cant-tell-idk-gif-7707829<|eor|><|eoss|><|endoftext|>
6
lolphp
newplayerentered
eudhoq1
<|soss|><|sot|>Awkward function and parameter names?<|eot|><|sost|>I'm rather new to PHP but I'm already hating it from day one. &#x200B; Function names like `implode()`, `explode()` The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way. &#x200B; And parameter names like `$needle` and `$haystack` in the `in_array()` function for example? There are times I wonder why can't they have more proper names. &#x200B; All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.<|eost|><|sor|>Can you suggest better names instead of in_array(), $needle, $haystack?<|eor|><|sor|>Sure; `array` and `item` work WAY better for anyone who hasn't heard that odd English saying before.<|eor|><|sor|>Searching a needle in a haystack is quite a common term... I guess to each his/her own<|eor|><|eoss|><|endoftext|>
5
lolphp
calligraphic-io
8qncp4
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|eoss|><|endoftext|>
9
lolphp
mort96
e0klx4r
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|sor|>Jokes in specs aren't that uncommon. [The HTTP error code 418 is widely considered to mean "I'm a teapot"](https://www.ietf.org/rfc/rfc2324.txt), and means that the client is trying to ask a teapot to brew coffee via HTCPCP. The [HTCPCP-TEA RFC](https://tools.ietf.org/html/rfc7168) extends HTCPCP to support teapots. [GNU's libc's manual pages](https://www.gnu.org/software/libc/manual/html_node/Aborting-a-Program.html) include a joke about abortion. This is more of a general lolprogrammerhumor thing than lolphp.<|eor|><|eoss|><|endoftext|>
55
lolphp
mort96
e0lgl0y
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|sor|>Jokes in specs aren't that uncommon. [The HTTP error code 418 is widely considered to mean "I'm a teapot"](https://www.ietf.org/rfc/rfc2324.txt), and means that the client is trying to ask a teapot to brew coffee via HTCPCP. The [HTCPCP-TEA RFC](https://tools.ietf.org/html/rfc7168) extends HTCPCP to support teapots. [GNU's libc's manual pages](https://www.gnu.org/software/libc/manual/html_node/Aborting-a-Program.html) include a joke about abortion. This is more of a general lolprogrammerhumor thing than lolphp.<|eor|><|soopr|>I was glad for Raymond Nicholson's patch earlier in the year, removing the political joke in the `glibc` manual `abort` entry. The joke added nothing to the docs, and I hate deeply partisan political commentary being injected into the open source community (c.f. `NPM`). The HTCPCP-TEA RFC has some deeper roots in the programming community. It's a reference to the [Utah teapot](https://en.wikipedia.org/wiki/Utah_teapot#/media/File:Utah_teapot_simple_2.png) that served as an early 3D rendering model, and is kept at the Computer History Museum in Mountain View. Around the time that RFC was submitted, there was a popular BOFH story about a sysadmin who had hooked the office coffee machine into his network and written a shell program to launch brewing a cup of coffee from his workstation. IMO, PHP isn't helped by the "Huggable Interface" standards proposal. It isn't clearly farcical to a non-native English speaker in the same way the tea pot proposal is.<|eoopr|><|sor|>It's worth noting that GNU, and the rest of the Free Software movement, is explicitly political in nature. Open source is just a way to build software, while free software is all about philosophy and politics. That doesn't mean I think the abortion joke is necessarily appropriate, but it's not politics being injected into a purely technical open source community.<|eor|><|eoss|><|endoftext|>
22
lolphp
xiongchiamiov
e0ktwfp
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|sor|>> Standard Markup link and bold formatting doesn't work in r/lolphp? It looks like you're using the r/redesign and the fancy pants editor, and so it escaped all your markdown for you. You want to switch to the markdown editor or use the wysiwyg features.<|eor|><|eoss|><|endoftext|>
13
lolphp
Crecket
e0lfo8l
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|sor|>Jokes in specs aren't that uncommon. [The HTTP error code 418 is widely considered to mean "I'm a teapot"](https://www.ietf.org/rfc/rfc2324.txt), and means that the client is trying to ask a teapot to brew coffee via HTCPCP. The [HTCPCP-TEA RFC](https://tools.ietf.org/html/rfc7168) extends HTCPCP to support teapots. [GNU's libc's manual pages](https://www.gnu.org/software/libc/manual/html_node/Aborting-a-Program.html) include a joke about abortion. This is more of a general lolprogrammerhumor thing than lolphp.<|eor|><|soopr|>I was glad for Raymond Nicholson's patch earlier in the year, removing the political joke in the `glibc` manual `abort` entry. The joke added nothing to the docs, and I hate deeply partisan political commentary being injected into the open source community (c.f. `NPM`). The HTCPCP-TEA RFC has some deeper roots in the programming community. It's a reference to the [Utah teapot](https://en.wikipedia.org/wiki/Utah_teapot#/media/File:Utah_teapot_simple_2.png) that served as an early 3D rendering model, and is kept at the Computer History Museum in Mountain View. Around the time that RFC was submitted, there was a popular BOFH story about a sysadmin who had hooked the office coffee machine into his network and written a shell program to launch brewing a cup of coffee from his workstation. IMO, PHP isn't helped by the "Huggable Interface" standards proposal. It isn't clearly farcical to a non-native English speaker in the same way the tea pot proposal is.<|eoopr|><|sor|>What? A Teapot protocol is obviously a joke to non native English speakers but a Huggable interface isn't? Have some fun once in a while lol<|eor|><|eoss|><|endoftext|>
13
lolphp
mort96
e0law9x
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|sor|>> Standard Markup link and bold formatting doesn't work in r/lolphp? It looks like you're using the r/redesign and the fancy pants editor, and so it escaped all your markdown for you. You want to switch to the markdown editor or use the wysiwyg features.<|eor|><|sor|>Or disable the redesign in preferences -> uncheck "Use the redesign as my default experience". As a bonus, you'll get a significantly faster website with higher information density.<|eor|><|eoss|><|endoftext|>
8
lolphp
mort96
e0lh54s
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|sor|>Jokes in specs aren't that uncommon. [The HTTP error code 418 is widely considered to mean "I'm a teapot"](https://www.ietf.org/rfc/rfc2324.txt), and means that the client is trying to ask a teapot to brew coffee via HTCPCP. The [HTCPCP-TEA RFC](https://tools.ietf.org/html/rfc7168) extends HTCPCP to support teapots. [GNU's libc's manual pages](https://www.gnu.org/software/libc/manual/html_node/Aborting-a-Program.html) include a joke about abortion. This is more of a general lolprogrammerhumor thing than lolphp.<|eor|><|soopr|>I was glad for Raymond Nicholson's patch earlier in the year, removing the political joke in the `glibc` manual `abort` entry. The joke added nothing to the docs, and I hate deeply partisan political commentary being injected into the open source community (c.f. `NPM`). The HTCPCP-TEA RFC has some deeper roots in the programming community. It's a reference to the [Utah teapot](https://en.wikipedia.org/wiki/Utah_teapot#/media/File:Utah_teapot_simple_2.png) that served as an early 3D rendering model, and is kept at the Computer History Museum in Mountain View. Around the time that RFC was submitted, there was a popular BOFH story about a sysadmin who had hooked the office coffee machine into his network and written a shell program to launch brewing a cup of coffee from his workstation. IMO, PHP isn't helped by the "Huggable Interface" standards proposal. It isn't clearly farcical to a non-native English speaker in the same way the tea pot proposal is.<|eoopr|><|sor|>What? A Teapot protocol is obviously a joke to non native English speakers but a Huggable interface isn't? Have some fun once in a while lol<|eor|><|soopr|>It's the difference of nouns vs. verbs. English nouns tend to be concrete - a teapot is a teapot. But English verbs are very fluid in their meanings, especially when used in a phrasal form (verb + preposition: `put on`, `put off`, `put down`). New words are often created in English by re-purposing existing verbs to a new meaning or retaining an archaic meaning - *turn on the computer* because we used to turn the knob to allow gas to flow to a gas light fixture, or simply using catch-all verbs that have dozens of meanings (`do` and `make` for example). Other languages I'm familiar with tend to have different verbs to describe different actions, and some way of generating new verbs to describe new actions: by building compound verbs (German), using verb prefixes (Russian), or using verb modifiers (Chinese). The fact that "huggable" might well have a technical meaning makes it a poor joke for an international audience, in addition to it just being a poor joke for a standards proposal.<|eoopr|><|sor|>I kind of agree actually, after all JavaScript semi-seriously suggested to name their array flattening function `smooch()` (because naming it `flatten()` would break stuff). I did have to read quite far to be 100% sure it was a joke and not a serious interface with a joke-y name. I just had to point out that PHP isn't the only language with jokes in specs :)<|eor|><|eoss|><|endoftext|>
8
lolphp
chinahawk
e0ksrag
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|sor|>PSR jokes never get old, especially if you realize that PSR itself, is a joke.<|eor|><|eoss|><|endoftext|>
7
lolphp
shvelo
e0lb8ym
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|sor|>Wholesome PHP<|eor|><|eoss|><|endoftext|>
6
lolphp
joske79
e0kkfbb
<|soss|><|sot|>PHP Standards Wikipedia Page: PSR-8<|eot|><|sost|>The Wikipedia [PHP Standards Recommendation](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) page looks similar to other technical Wikipedia pages for other mainstream, serious programming languages. Until you get. to. this. "gem": PSR-8 Huggable Interface *It establishes a common way for objects to express mutual appreciation and support by hugging. This allows objects to support each other in a constructive fashion, furthering cooperation between different PHP projects.* Only in PHP.<|eost|><|sor|>How sweet<|eor|><|eoss|><|endoftext|>
5
lolphp
quchen
2l2cvf
<|sols|><|sot|>Good format to represent arbitrary size/precision numbers? String!<|eot|><|sol|>http://php.net/manual/en/intro.bc.php<|eol|><|eols|><|endoftext|>
11
lolphp
Benutzername
clrjxy3
<|sols|><|sot|>Good format to represent arbitrary size/precision numbers? String!<|eot|><|sol|>http://php.net/manual/en/intro.bc.php<|eol|><|sor|>Similar to http://docs.oracle.com/javase/6/docs/api/java/math/BigInteger.html#BigInteger(java.lang.String) no?<|eor|><|sor|>That's just a convenience constructor. Internally it's a byte array.<|eor|><|sor|>Which is exactly what PHP Strings are. $x = "abc"; echo $x[1]; Output: "b".<|eor|><|sor|>No, the Java BigInteger class encodes the actual number as bytes, not the characters of the string. For example, "255" would be parsed as the byte array {0xFF} and a boolean containing the sign (it's more complicated than that, but you get the idea). After that, math can be done directly on the bytes instead of having to re parse the strings all the time.<|eor|><|eols|><|endoftext|>
14
lolphp
quchen
cm09ws9
<|sols|><|sot|>Good format to represent arbitrary size/precision numbers? String!<|eot|><|sol|>http://php.net/manual/en/intro.bc.php<|eol|><|soopr|>And I don't mean "string internally". The functions literally take string arguments. string bcadd ( string $left_operand , string $right_operand [, int $scale ] ) string bcmul ( string $left_operand = "" , string $right_operand = "" [, int $scale = int ] ) // and so on<|eoopr|><|sor|>Yes, the bcmatch library does. It does in C, too. What's your point? This isn't the only bignum library PHP has (there's also GMP). This isn't a lolphp.<|eor|><|soopr|>I think it's extremely bad design, and I haven't encountered it anywhere else. I pity those other places that use the same interface just the same way.<|eoopr|><|sor|>Why is it bad design? Performing decimal arithmetic isn't really that unusual of a use-case. And for some operations, where you're taking string input and giving string output, doing the binary transform in the middle is inefficient.<|eor|><|soopr|>- Almost all strings are not numbers, so almost all well-typed inputs make this function crash. You therefore need to parse and prettyprint intermediate results on every operation, and handle errors accordingly. - strings are very wasteful for storing numbers, taking at least a byte per digit. That's 1-2 orders of magnitude worse than direct encoding. - The number-string "01234" could represent a lot of things. It's valid in any base larger than 4, and the leading zero could hint that it's octal. It could also be an ordinary string of text. Things like these require a lot of documentation, and this can only partially clarify pitfalls. Example: adding a leading zero to a number in stringly notation should not change its value. However, this might lead to octal interpretation here, and stuff breaks. - I can't think of a valid use case for decimal arithmetic. If it's user input you have to validate it as correct, so you've already parsed it, and might as well use a proper number representation that comes out almost as a side effect, and which is base-independent. If it's not user input then I don't see base 10 coming up anywhere.<|eoopr|><|eols|><|endoftext|>
7
lolphp
powerofmightyatom
cltwudv
<|sols|><|sot|>Good format to represent arbitrary size/precision numbers? String!<|eot|><|sol|>http://php.net/manual/en/intro.bc.php<|eol|><|soopr|>And I don't mean "string internally". The functions literally take string arguments. string bcadd ( string $left_operand , string $right_operand [, int $scale ] ) string bcmul ( string $left_operand = "" , string $right_operand = "" [, int $scale = int ] ) // and so on<|eoopr|><|sor|>PHP is clearly developed by Enteprise IT programmers. We fucking love strings over here. Saves so much time on interface design.<|eor|><|eols|><|endoftext|>
6
lolphp
Benutzername
clr2xg9
<|sols|><|sot|>Good format to represent arbitrary size/precision numbers? String!<|eot|><|sol|>http://php.net/manual/en/intro.bc.php<|eol|><|sor|>Similar to http://docs.oracle.com/javase/6/docs/api/java/math/BigInteger.html#BigInteger(java.lang.String) no?<|eor|><|sor|>That's just a convenience constructor. Internally it's a byte array.<|eor|><|eols|><|endoftext|>
6
lolphp
quchen
clqs3bc
<|sols|><|sot|>Good format to represent arbitrary size/precision numbers? String!<|eot|><|sol|>http://php.net/manual/en/intro.bc.php<|eol|><|soopr|>And I don't mean "string internally". The functions literally take string arguments. string bcadd ( string $left_operand , string $right_operand [, int $scale ] ) string bcmul ( string $left_operand = "" , string $right_operand = "" [, int $scale = int ] ) // and so on<|eoopr|><|eols|><|endoftext|>
5
lolphp
Goz3rr
27sizw
<|sols|><|sot|>Argument 1 must be an instance of string, string given<|eot|><|sol|>https://eval.in/160610<|eol|><|eols|><|endoftext|>
13
lolphp
Goz3rr
ci3x6fj
<|sols|><|sot|>Argument 1 must be an instance of string, string given<|eot|><|sol|>https://eval.in/160610<|eol|><|soopr|>This is because you can only type hint classes (and arrays for whatever reason), for this to compile you would have to: class string {} function lolphp(string $data) {} lolphp(new string); So, in PHP it's possible for a string to be a string except when it's actually a string <|eoopr|><|eols|><|endoftext|>
17
lolphp
kageurufu
ci42xfo
<|sols|><|sot|>Argument 1 must be an instance of string, string given<|eot|><|sol|>https://eval.in/160610<|eol|><|sor|>PHP doesn't support type hinting for scalar types. What a stupid post.<|eor|><|sor|>what a stupid issue with their type hinting... this is a pretty important failure in php<|eor|><|eols|><|endoftext|>
15
lolphp
kageurufu
ci4b38n
<|sols|><|sot|>Argument 1 must be an instance of string, string given<|eot|><|sol|>https://eval.in/160610<|eol|><|sor|>PHP doesn't support type hinting for scalar types. What a stupid post.<|eor|><|sor|>what a stupid issue with their type hinting... this is a pretty important failure in php<|eor|><|sor|>How is this a stupid issue, or an important failure?<|eor|><|sor|>Type hinting should be complete, this is completely counter-intuitive. When I use C, and declare int something(string else); , I know it will only accept a string and return an int. If php wants to introduce type hinting, it should at least do the same. this is why Hack is a better solution than PHP itself at this point<|eor|><|eols|><|endoftext|>
7
lolphp
Daniel15
27quqv
<|sols|><|sot|>Redefining true<|eot|><|sol|>https://eval.in/160294<|eol|><|eols|><|endoftext|>
10
lolphp
PhyxsiusPrime
ci3nxuf
<|sols|><|sot|>Redefining true<|eot|><|sol|>https://eval.in/160294<|eol|><|sor|>You can do it in Python 2 too: >>> False = True >>> if False : print 'hahaha' ... hahaha <|eor|><|soopr|>That's really strange. Surely built-in values like False and True should be constants and you shouldn't be allowed to shadow them with local variables, which is what I assume is going on here. :(<|eoopr|><|sor|>It's for backward compatibility iirc. Earlier versions of Python did not have False or True constants, so people would occasionally define local variables called False or True, which could in theory be something like 'True = 1' in contexts where that made sense (like, say, a parser of some kind). Rather than break those scripts, they simply made False and True redefinable. In Python 3, they were breaking backward compatibility anyway, so they went ahead and gave those constants more logical behavior. <|eor|><|eols|><|endoftext|>
11
lolphp
vytah
ci3hf1y
<|sols|><|sot|>Redefining true<|eot|><|sol|>https://eval.in/160294<|eol|><|sor|>You can do it in Python 2 too: >>> False = True >>> if False : print 'hahaha' ... hahaha <|eor|><|eols|><|endoftext|>
10
lolphp
Daniel15
ci3li3u
<|sols|><|sot|>Redefining true<|eot|><|sol|>https://eval.in/160294<|eol|><|soopr|>More lols: It doesn't work if you're not in a namespace. https://eval.in/160329<|eoopr|><|eols|><|endoftext|>
9
lolphp
shillbert
ci3o3lu
<|sols|><|sot|>Redefining true<|eot|><|sol|>https://eval.in/160294<|eol|><|sor|>You can do it in C too. Oh wait, C doesn't even *have* booleans; I'm thinking of C++.<|eor|><|sor|>Well, C99 does.<|eor|><|sor|>You and your fancy C99. I like to maintain compatibility with Turbo C 2.0 and Visual C++ 2010.<|eor|><|eols|><|endoftext|>
8
lolphp
legoktm
ci3jzbs
<|sols|><|sot|>Redefining true<|eot|><|sol|>https://eval.in/160294<|eol|><|sor|>You can do it in Python 2 too: >>> False = True >>> if False : print 'hahaha' ... hahaha <|eor|><|sor|>Thankfully you can no longer do that in Python 3.<|eor|><|eols|><|endoftext|>
7
lolphp
Daniel15
ci3gg3v
<|sols|><|sot|>Redefining true<|eot|><|sol|>https://eval.in/160294<|eol|><|soopr|> <?php namespace lolphp; define('lolphp\\true', false); var_dump(true); // bool(false)<|eoopr|><|eols|><|endoftext|>
5
lolphp
Daniel15
ci3lh5p
<|sols|><|sot|>Redefining true<|eot|><|sol|>https://eval.in/160294<|eol|><|sor|>You can do it in Python 2 too: >>> False = True >>> if False : print 'hahaha' ... hahaha <|eor|><|soopr|>That's really strange. Surely built-in values like False and True should be constants and you shouldn't be allowed to shadow them with local variables, which is what I assume is going on here. :(<|eoopr|><|eols|><|endoftext|>
5
lolphp
terrorobe
1xwtoj
<|sols|><|sot|>"Reading two form elements with same name" - that's an interesting problem, PHP has you covered!<|eot|><|sol|>http://stackoverflow.com/questions/5643981/reading-two-form-elements-with-same-name<|eol|><|eols|><|endoftext|>
12
lolphp
zerro_4
cffez64
<|sols|><|sot|>"Reading two form elements with same name" - that's an interesting problem, PHP has you covered!<|eot|><|sol|>http://stackoverflow.com/questions/5643981/reading-two-form-elements-with-same-name<|eol|><|sor|>You can also give an index to the array (string or number), so technically they *don't* have the same name, but to PHP they're still in the same array or input values: Name: <input type="text" name="fname[0]" /> <input type="hidden" name="fname[1]" value="test" /> or Name: <input type="text" name="fname[text]" /> <input type="hidden" name="fname[hidden]" value="test" /> <|eor|><|sor|>The OP in the SO article insisted they can't be an array. It's like he's asking how to put a nail in a board, and everyone is showing him a variety of hammers, but he insists on using a spoon. <|eor|><|eols|><|endoftext|>
16
lolphp
Matt3k
cffpodx
<|sols|><|sot|>"Reading two form elements with same name" - that's an interesting problem, PHP has you covered!<|eot|><|sol|>http://stackoverflow.com/questions/5643981/reading-two-form-elements-with-same-name<|eol|><|sor|>I don't see what's amusing about this.<|eor|><|sor|>The fact that you have to adapt your form's element names to accommodate standard HTML form behavior - I think.<|eor|><|eols|><|endoftext|>
13