subreddit stringclasses 7 values | author stringlengths 3 20 | id stringlengths 5 7 | content stringlengths 67 30.4k | score int64 0 140k |
|---|---|---|---|---|
lolphp | nyamsprod | ar8q8r | <|sols|><|sot|>DateInterval sadness.. this one is a 10 year old bug!!!<|eot|><|sol|>https://3v4l.org/JRlDG<|eol|><|eols|><|endoftext|> | 19 |
lolphp | Sandbucketman | egljthc | <|sols|><|sot|>DateInterval sadness.. this one is a 10 year old bug!!!<|eot|><|sol|>https://3v4l.org/JRlDG<|eol|><|sor|>I think people aren't quite grasping what is really going on here and the rabbit hole goes much deeper.
DateIntervals are simply not compareable. The support doesn't exist within PHP and while nearly 10 years ago someone submitted a request to have this patched and even provided a solution it did not make it to the trunk:
https://bugs.php.net/bug.php?id=49914
It is already very strange that `DateInterval::createFromDateString('foobar')`
doesn't return false but instead creates an empty object but when I created a DateInterval object with actual values in it and compared them **it still returned true**.
The workaround is to parse it to a DateTime object since those **are** compareable but there's an extra layer of wtf going on here.
Some more tests and information here:
https://stackoverflow.com/questions/9547855/are-php-dateinterval-comparable-like-datetime<|eor|><|eols|><|endoftext|> | 20 |
lolphp | nyamsprod | egliukb | <|sols|><|sot|>DateInterval sadness.. this one is a 10 year old bug!!!<|eot|><|sol|>https://3v4l.org/JRlDG<|eol|><|sor|>Please give some description of what is happening and what should happen for us non php people.<|eor|><|soopr|>Instead of failing by throwing an exception or returning false... createFromDateString returns an interval of 0 seconds ...<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | iheartrms | 3alb08 | <|sols|><|sot|>Encoding Web Shells in PNG IDAT chunks | Application Security<|eot|><|sol|>https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/<|eol|><|eols|><|endoftext|> | 20 |
lolphp | Jonno_FTW | csef4x9 | <|sols|><|sot|>Encoding Web Shells in PNG IDAT chunks | Application Security<|eot|><|sol|>https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/<|eol|><|sor|>[deleted]<|eor|><|sor|>I get to be that person this time :-)
So, what is happening here is that when you configure nginx with FastCGI (regardless of whether your backend language is PHP, Perl, etc..) and allow user-controlled uploads on the site (say PNGs for their forum avatar), there's an easy way to shoot yourself in the foot.
The CGI spec allows translating paths like the following: /index.php/Hello, into running the index.php, but showing the appropriate page for 'Hello' (MediaWiki can use this for URLs like /index.php/Main_Page instead of /index.php?title=Main_Page).
But a common nginx configuration allows for all URLs ending in your CGI extension to be passed to your FastCGI server. So if a user uploads /user/1/avatar.png, then navigates to /user/1/avatar.png/whatever.php in their browser, the contents of avatar.png will be executed as a PHP script, allowing them remote code execution.
The article discusses how to encode the malicious code into the PNG IDAT segments, which can survive resizing or other image transformations (since many forums will resize or otherwise transform your avatar automatically).
One thing that makes it more common for PHP scripts is that PHP allows itself to be included anywhere on the page via <?php ?> sections, so you can have both a valid image and valid PHP, making it possible to evade some types of validation. ASP tags and similar will act the same way. Normal Perl or [Insert-Your-Favorite] scripts can get caught if there is an 'Is this an image?' validator, but on arbitrary uploads, they can also be exploited with this nginx configuration if you have them as a FastCGI backend.
edit: if you're interested in protecting your own nginx server, there's some suggestions [here](http://wiki.nginx.org/Pitfalls#Passing_Uncontrolled_Requests_to_PHP). But additionally, if your software supports it, it's better to keep your user uploads on their own server that specifically serves static files, to prevent accidentally sending them through your FastCGI server.<|eor|><|sor|>So this is more lolfcgi than lolphp?<|eor|><|eols|><|endoftext|> | 7 |
lolphp | TimeToogo | 2efehz | <|sols|><|sot|>Closures and relative constants weirdness<|eot|><|sol|>http://3v4l.org/6loRa<|eol|><|eols|><|endoftext|> | 19 |
lolphp | tdammers | cjyyo5g | <|sols|><|sot|>Closures and relative constants weirdness<|eot|><|sol|>http://3v4l.org/6loRa<|eol|><|soopr|>I cannot understand this behaviour.
Why would when the closure is defined affect the output?
HHVM gets it right.<|eoopr|><|sor|>> Why would when the closure is defined affect the output?
Because the PHP parser/compiler/interpreter is a big messy ball of band-aids upon band-aids, written by people who were running into the basics of compiler theory as they went, whereas HHVM had a lot of thought put into it, by people with a bit of a CS background who actually knew what they were doing.
PHP features are usually implemented like this:
1. Hear about a feature that some other language has.
2. Hack PHP to support a simple use case that looks about right.
3. Ship it.
4. Receive bug report: not-so-simple use case breaks.
5. Apply band-aid to support this particular not-so-simple use case. Go back to 3.
Features in other languages are usually implemented like this:
1. Hear about a feature that some other language has.
2. Dissect that feature in the other language to develop a thorough understanding of it.
3. Think about how the feature would fit into your own language's semantics and syntax, discuss with the community.
4. Implement a toy version, experiment with it to see what the consequences are.
5. Write a formal specification for the feature. Have it reviewed by the community.
6. Write tests according to the specification. Have them reviewed for completeness, coverage, and correctness, by the community.
7. Implement the feature. Be religious about having all the tests passed, including existing regression tests.
8. Ship a beta.
9. Address any concerns that arise. Go back to 3. as needed.
10. Ship it.<|eor|><|eols|><|endoftext|> | 21 |
lolphp | nikic | cjz0qcb | <|sols|><|sot|>Closures and relative constants weirdness<|eot|><|sol|>http://3v4l.org/6loRa<|eol|><|soopr|>I cannot understand this behaviour.
Why would when the closure is defined affect the output?
HHVM gets it right.<|eoopr|><|sor|>> Why would when the closure is defined affect the output?
Because the PHP parser/compiler/interpreter is a big messy ball of band-aids upon band-aids, written by people who were running into the basics of compiler theory as they went, whereas HHVM had a lot of thought put into it, by people with a bit of a CS background who actually knew what they were doing.
PHP features are usually implemented like this:
1. Hear about a feature that some other language has.
2. Hack PHP to support a simple use case that looks about right.
3. Ship it.
4. Receive bug report: not-so-simple use case breaks.
5. Apply band-aid to support this particular not-so-simple use case. Go back to 3.
Features in other languages are usually implemented like this:
1. Hear about a feature that some other language has.
2. Dissect that feature in the other language to develop a thorough understanding of it.
3. Think about how the feature would fit into your own language's semantics and syntax, discuss with the community.
4. Implement a toy version, experiment with it to see what the consequences are.
5. Write a formal specification for the feature. Have it reviewed by the community.
6. Write tests according to the specification. Have them reviewed for completeness, coverage, and correctness, by the community.
7. Implement the feature. Be religious about having all the tests passed, including existing regression tests.
8. Ship a beta.
9. Address any concerns that arise. Go back to 3. as needed.
10. Ship it.<|eor|><|sor|>As someone working on PHP, your description of how "other languages" work appears to very closely describe the process for implementing features in PHP.
After you have implemented a feature in a separate branch you write an RFC (which includes both formal specification for the feature and explains why it should be implemented and why it should be implemented in this way). The provided implementation must have comprehensive test coverage and, obviously, also pass any existing tests. After both the RFC and implementation are reviewed the proposal is accepted by supermajority vote. After it has landed, PHP will go through several months of betas and RCs to resolve unanticipated issues.
So yeah, pretty much what you said. (Note: This process only applies since about PHP 5.4.)<|eor|><|eols|><|endoftext|> | 10 |
lolphp | nikic | cjz3dxy | <|sols|><|sot|>Closures and relative constants weirdness<|eot|><|sol|>http://3v4l.org/6loRa<|eol|><|soopr|>I cannot understand this behaviour.
Why would when the closure is defined affect the output?
HHVM gets it right.<|eoopr|><|sor|>> Why would when the closure is defined affect the output?
Because the PHP parser/compiler/interpreter is a big messy ball of band-aids upon band-aids, written by people who were running into the basics of compiler theory as they went, whereas HHVM had a lot of thought put into it, by people with a bit of a CS background who actually knew what they were doing.
PHP features are usually implemented like this:
1. Hear about a feature that some other language has.
2. Hack PHP to support a simple use case that looks about right.
3. Ship it.
4. Receive bug report: not-so-simple use case breaks.
5. Apply band-aid to support this particular not-so-simple use case. Go back to 3.
Features in other languages are usually implemented like this:
1. Hear about a feature that some other language has.
2. Dissect that feature in the other language to develop a thorough understanding of it.
3. Think about how the feature would fit into your own language's semantics and syntax, discuss with the community.
4. Implement a toy version, experiment with it to see what the consequences are.
5. Write a formal specification for the feature. Have it reviewed by the community.
6. Write tests according to the specification. Have them reviewed for completeness, coverage, and correctness, by the community.
7. Implement the feature. Be religious about having all the tests passed, including existing regression tests.
8. Ship a beta.
9. Address any concerns that arise. Go back to 3. as needed.
10. Ship it.<|eor|><|sor|>As someone working on PHP, your description of how "other languages" work appears to very closely describe the process for implementing features in PHP.
After you have implemented a feature in a separate branch you write an RFC (which includes both formal specification for the feature and explains why it should be implemented and why it should be implemented in this way). The provided implementation must have comprehensive test coverage and, obviously, also pass any existing tests. After both the RFC and implementation are reviewed the proposal is accepted by supermajority vote. After it has landed, PHP will go through several months of betas and RCs to resolve unanticipated issues.
So yeah, pretty much what you said. (Note: This process only applies since about PHP 5.4.)<|eor|><|sor|>> As someone working on PHP
Do you have any insight on the problem OP outlined?<|eor|><|sor|>It's a known problem with namespace resolution of unqualified constants and functions. A constant `FOO` can refer either to `FOO` or `namespace\FOO`. When the VM first reaches such a constant access it will determine which one it is and cache the value. In the case that `FOO` was cached and `namespace\FOO` was defined afterwards, the cached value will be invalid.
In order to fix this one would have to remove the cache (very bad for perf) or figure out how to properly invalidate this cache.
I think I just figured out how we might do the latter...<|eor|><|eols|><|endoftext|> | 8 |
lolphp | terrorobe | cjz2mdt | <|sols|><|sot|>Closures and relative constants weirdness<|eot|><|sol|>http://3v4l.org/6loRa<|eol|><|soopr|>I cannot understand this behaviour.
Why would when the closure is defined affect the output?
HHVM gets it right.<|eoopr|><|sor|>> Why would when the closure is defined affect the output?
Because the PHP parser/compiler/interpreter is a big messy ball of band-aids upon band-aids, written by people who were running into the basics of compiler theory as they went, whereas HHVM had a lot of thought put into it, by people with a bit of a CS background who actually knew what they were doing.
PHP features are usually implemented like this:
1. Hear about a feature that some other language has.
2. Hack PHP to support a simple use case that looks about right.
3. Ship it.
4. Receive bug report: not-so-simple use case breaks.
5. Apply band-aid to support this particular not-so-simple use case. Go back to 3.
Features in other languages are usually implemented like this:
1. Hear about a feature that some other language has.
2. Dissect that feature in the other language to develop a thorough understanding of it.
3. Think about how the feature would fit into your own language's semantics and syntax, discuss with the community.
4. Implement a toy version, experiment with it to see what the consequences are.
5. Write a formal specification for the feature. Have it reviewed by the community.
6. Write tests according to the specification. Have them reviewed for completeness, coverage, and correctness, by the community.
7. Implement the feature. Be religious about having all the tests passed, including existing regression tests.
8. Ship a beta.
9. Address any concerns that arise. Go back to 3. as needed.
10. Ship it.<|eor|><|sor|>As someone working on PHP, your description of how "other languages" work appears to very closely describe the process for implementing features in PHP.
After you have implemented a feature in a separate branch you write an RFC (which includes both formal specification for the feature and explains why it should be implemented and why it should be implemented in this way). The provided implementation must have comprehensive test coverage and, obviously, also pass any existing tests. After both the RFC and implementation are reviewed the proposal is accepted by supermajority vote. After it has landed, PHP will go through several months of betas and RCs to resolve unanticipated issues.
So yeah, pretty much what you said. (Note: This process only applies since about PHP 5.4.)<|eor|><|sor|>> As someone working on PHP
Do you have any insight on the problem OP outlined?<|eor|><|eols|><|endoftext|> | 6 |
lolphp | shitbangs | 2dbvc1 | <|sols|><|sot|>lolPHP *and* HHVM<|eot|><|sol|>http://3v4l.org/qDQa2<|eol|><|eols|><|endoftext|> | 20 |
lolphp | shitbangs | cjnzt23 | <|sols|><|sot|>lolPHP *and* HHVM<|eot|><|sol|>http://3v4l.org/qDQa2<|eol|><|soopr|>All of these are wrong because according to [the documentation](http://php.net/manual/en/class.reflectionfunctionabstract.php), ReflectionFunctionAbstract implements [Reflector](http://php.net/manual/en/class.reflector.php) which contains public static function *export*. Yet, PHP >= 5.2 eats it like cake.
Enter HHVM which has invented new abstract methods so it breaks but with completely unexpected fatal errors. Also, "getAttributesRecursive" on a function?!
EDIT: breaks [their own docs](http://docs.hhvm.com/manual/en/class.reflectionfunctionabstract.php) as well<|eoopr|><|eols|><|endoftext|> | 11 |
lolphp | ChoHag | cjo0zuc | <|sols|><|sot|>lolPHP *and* HHVM<|eot|><|sol|>http://3v4l.org/qDQa2<|eol|><|sor|>At least the exit code is consistent.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | shitbangs | cjo1ddi | <|sols|><|sot|>lolPHP *and* HHVM<|eot|><|sol|>http://3v4l.org/qDQa2<|eol|><|soopr|>All of these are wrong because according to [the documentation](http://php.net/manual/en/class.reflectionfunctionabstract.php), ReflectionFunctionAbstract implements [Reflector](http://php.net/manual/en/class.reflector.php) which contains public static function *export*. Yet, PHP >= 5.2 eats it like cake.
Enter HHVM which has invented new abstract methods so it breaks but with completely unexpected fatal errors. Also, "getAttributesRecursive" on a function?!
EDIT: breaks [their own docs](http://docs.hhvm.com/manual/en/class.reflectionfunctionabstract.php) as well<|eoopr|><|sor|>How about that new standard spec?<|eor|><|soopr|>It covers the language, not the extensions<|eoopr|><|eols|><|endoftext|> | 7 |
lolphp | pitiless | 2avzlh | <|sols|><|sot|>$errors = $user<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-login.php#L799<|eol|><|eols|><|endoftext|> | 20 |
lolphp | DCoder1337 | cj040y1 | <|sols|><|sot|>$errors = $user<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-login.php#L799<|eol|><|sor|>You linked to line 799 of `master`, which is a moving target. A change to that file has been made since you linked to it, which threw off your line numbers.
If you link to a specific revision instead (for example, [this link](https://github.com/WordPress/WordPress/blob/097dc8ee15b186b6dea2a11f58a24036f111a095/wp-login.php#L804) ), the link will work much better.<|eor|><|eols|><|endoftext|> | 19 |
lolphp | sloat | cizj35y | <|sols|><|sot|>$errors = $user<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-login.php#L799<|eol|><|sor|>I thought nobody wrote code like this anymore... https://github.com/WordPress/WordPress/blob/master/wp-login.php#L241-L253<|eor|><|sor|>If you want to know true horror, look at [wp-db.php](https://github.com/WordPress/WordPress/blob/master/wp-includes/wp-db.php)
I don't hate myself enough to delve deeper, but I found the 7 different query parameter escaping functions particularly fun. Also the property $is_mysql, which is always true, and doesn't seem to be checked anywhere.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | allthediamonds | ciztjp5 | <|sols|><|sot|>$errors = $user<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-login.php#L799<|eol|><|sor|>[deleted]<|eor|><|sor|>Actually, this is the root of all other PHP's problems: no one has the slightest idea of what they're doing. It's the blind leading the blind.
<|eor|><|eols|><|endoftext|> | 11 |
lolphp | allthediamonds | cizeovq | <|sols|><|sot|>$errors = $user<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-login.php#L799<|eol|><|sor|>I thought nobody wrote code like this anymore... https://github.com/WordPress/WordPress/blob/master/wp-login.php#L241-L253<|eor|><|eols|><|endoftext|> | 9 |
lolphp | urquan | cj093m4 | <|sols|><|sot|>$errors = $user<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-login.php#L799<|eol|><|sor|>You linked to line 799 of `master`, which is a moving target. A change to that file has been made since you linked to it, which threw off your line numbers.
If you link to a specific revision instead (for example, [this link](https://github.com/WordPress/WordPress/blob/097dc8ee15b186b6dea2a11f58a24036f111a095/wp-login.php#L804) ), the link will work much better.<|eor|><|soopr|>Oops - I should've though of that, thanks!<|eoopr|><|sor|>Tip: highlight the line you want to link to, press 'y', and you will have a link to the latest relevant commit.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Varriount | 23ubnq | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|eols|><|endoftext|> | 19 |
lolphp | allthediamonds | ch0t5d2 | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>> Every language has unintuitive partsPHP more than mostbut if you're an intelligent programmer, you can avoid them.
No. No, no, no. NO.
I don't have to be on the lookout for a language that is trying to make me trip and fall on every fucking step. I should have proper tools that protect me from my mistakes instead of creating traps for me to fall on.
God, I hate PHP apologists even more than I hate PHP itself.<|eor|><|eols|><|endoftext|> | 27 |
lolphp | ajmarks | ch0qo7k | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>Dude actually says PHP's string functions are consistent? WTF?!?<|eor|><|eols|><|endoftext|> | 20 |
lolphp | ajmarks | ch1m8sc | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>Dude actually says PHP's string functions are consistent? WTF?!?<|eor|><|sor|>Corrected. Should've seen that bomb before it exploded in my face. TBH, though, I haven't thought about that for years, ever since autocomplete was a thing. I type in array_*`<tab>` or str*`<tab>`, and fill in the needle and haystack in whatever order the IDE tells me to do it (same as any other language I've use).<|eor|><|sor|>Your article is still missing the meat of the Fractal article. You don't touch the crazy coercion issues, the lack of real data structures, the lack of proper debugging, the configuration-in-19-gajillion-places problem, the over-filled primary namespace, the fact that the php team is, based on their responses to bug reports, probably suffering from some sort of developmental disorder, and so on.<|eor|><|eols|><|endoftext|> | 19 |
lolphp | jmcs | ch0t49x | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>> Whatever the future holds, PHP will continue to be a relevant and important language for web development.<|eor|><|sor|>And Kim family will continue to rule North Korea. Both affirmations are probably true and neither is a good thing.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | jmcs | ch0t3ai | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>I think the easiest way to end PHP's reign of terror is to make another language that's as easy to use and deploy as PHP and then port every popular PHP platform to it.
I'd love to stop writing PHP but it's the easiest way to whip up a simple one-page app and it's powering platforms like Wordpress and Magento that thousands or millions of sites use.<|eor|><|sor|>The problem is that what many people call easy includes really bad stuff like silently ignoring errors.<|eor|><|eols|><|endoftext|> | 16 |
lolphp | nahguri | ch2ehy5 | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>Dude actually says PHP's string functions are consistent? WTF?!?<|eor|><|sor|>Corrected. Should've seen that bomb before it exploded in my face. TBH, though, I haven't thought about that for years, ever since autocomplete was a thing. I type in array_*`<tab>` or str*`<tab>`, and fill in the needle and haystack in whatever order the IDE tells me to do it (same as any other language I've use).<|eor|><|sor|>Your article is still missing the meat of the Fractal article. You don't touch the crazy coercion issues, the lack of real data structures, the lack of proper debugging, the configuration-in-19-gajillion-places problem, the over-filled primary namespace, the fact that the php team is, based on their responses to bug reports, probably suffering from some sort of developmental disorder, and so on.<|eor|><|sor|>In short, the article doesn't address shit.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | jmcs | ch0tf01 | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>I think the easiest way to end PHP's reign of terror is to make another language that's as easy to use and deploy as PHP and then port every popular PHP platform to it.
I'd love to stop writing PHP but it's the easiest way to whip up a simple one-page app and it's powering platforms like Wordpress and Magento that thousands or millions of sites use.<|eor|><|sor|>The problem is that what many people call easy includes really bad stuff like silently ignoring errors.<|eor|><|sor|>Maybe that "bad stuff" is really something people want. Just like the number one requirement for most people when shopping for cars is "does it have enough cup holders."<|eor|><|sor|>The problem is that the kind of people that want the bad stuff shouldn't be allowed to make important decisions, because they are the same kind of people that store plain text or unsalted passwords, that think proper design patterns is a thing that happens to others, and that will make unmanageable stuff.
10 in 10 psychologists will tell you shouldn't enable delusional people, and PHP does that to people that have somehow convinced themselves they are developers.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | allthediamonds | ch1koid | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>> Every language has unintuitive partsPHP more than mostbut if you're an intelligent programmer, you can avoid them.
No. No, no, no. NO.
I don't have to be on the lookout for a language that is trying to make me trip and fall on every fucking step. I should have proper tools that protect me from my mistakes instead of creating traps for me to fall on.
God, I hate PHP apologists even more than I hate PHP itself.<|eor|><|sor|>>> Every language has unintuitive partsPHP more than mostbut if you're an intelligent programmer, you can avoid them.
>
>
> No. No, no, no. NO.
The sad part is that a *lot* of the pitfalls are completely avoidable.
> I don't have to be on the lookout for a language that is trying to make me trip and fall on every fucking step.
I thought the same about C while in college (I had taught myself programming using the Turbo Pascal compiler and the manuals) and it rubbed me the wrong way because I knew the gotchas in C *were* avoidable in a computer language... After graduating I went on to get employment where I was forced to use PHP, while teaching myself Ada -- and again it hit me just how much pain could be completely avoided.
> I should have proper tools that protect me from my mistakes instead of creating traps for me to fall on.
Totally agreed.
> God, I hate PHP apologists even more than I hate PHP itself.
The worst thing about them is that they refuse to even consider alternative solutions... it's almost like they completely misunderstand the implications of any computer-science theory.<|eor|><|sor|>> The sad part is that a lot of the pitfalls are completely avoidable.
Of course they are! I work with PHP, I've learned to avoid most pitfalls by now. That's not a excuse, though: I shouldn't need to remember to pass TRUE as the third argument to in_array, to use array_merge instead of + because for some reason + does an associative union, to switch around the order of the arguments between array_map and array_filter, ...
> I knew the gotchas in C were avoidable in a computer language...
Well, C does have an excuse: it's old, it's low-level and it's blazing fast. Some of its "carelessness" are there by design, and at the very least they probably made sense forty years ago. PHP is relatively new, it's high level and it's so slow the measly application I work on need to run three levels of caching plus Varnish.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | Varriount | ch0nrl8 | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|soopr|>And for even more fun, one only has to look at the pro-php'ers trying to defend [the post on /r/programming !](http://www.reddit.com/r/programming/comments/23qpa9/php_it_doesnt_have_to_be_a_bad_experience/ )
My favorite comment is [here](http://www.reddit.com/r/programming/comments/23qpa9/php_it_doesnt_have_to_be_a_bad_experience/cgzwbj2) . The poster says that no defense can be made with regards to php's design... and then goes on to defend php (albeit indirectly as a refutation of the "fractal of bad design" post)<|eoopr|><|eols|><|endoftext|> | 12 |
lolphp | OneWingedShark | ch1ihl4 | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>I think the easiest way to end PHP's reign of terror is to make another language that's as easy to use and deploy as PHP and then port every popular PHP platform to it.
I'd love to stop writing PHP but it's the easiest way to whip up a simple one-page app and it's powering platforms like Wordpress and Magento that thousands or millions of sites use.<|eor|><|sor|>It seems the only option at this point is Node.js... and, well... it's JS.
</facepalm>
I think a lot of people (in this thread, over in /r/programming, etc.) are reading way too much into this. Nowhere in the OP did I say "PHP is the *right* language for web development", nor "PHP is *always* the best tool for the job". But rather: "it's pretty good in almost every way that counts for web development".
The gist of the post is: PHP is not going away (for a very long time). A lot of people still develop with PHP, and there are many things these developers can do (and newer language features) that make developing in PHP not-so-bad.<|eor|><|sor|>> "it's pretty good in almost every way that counts for web development".
If you're excluding sensitive/critical information-processing I'd be inclined to agree -- but I know of several large codebases in PHP which handle ***medical records***, something that, IMO, should *not* be touched by PHP.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | EsperSpirit | ch15vet | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>If all PHP was like those examples, we wouldn't even need this subreddit.
PHP may be weird and dodgy in places, but a language like Ruby is just as horrible in its design (or even Python, which just does bad design in a different direction); the main problem with PHP is that it *encourages bad practice* and has poor documentation, as well as having provisions it shouldn't (ignoring errors == WHAT THE FUCK, WHY?!; but even things like short_open_tag are a bad idea and if they were removed, PHP would still be WTF-worthy, but at least significantly improved).<|eor|><|sor|>Can you give an example of Python doing "bad design in a different direction"?<|eor|><|sor|>Whitespace.
Possibly the fault of the code (I'm not a dev myself, just hacked stuff together in various languages when circumstances must), but it also seems slow for what it does compared to perl, and I may be looking in the wrong place, but the documentation seems very variable and I rapidly find my browser window holding half of stack overflow.<|eor|><|sor|>If you're refering to Python's use of indention instead of curly braces, this is actually better design than most languages. Python's indention never lies to you. C-like curly braces can easily hide unintended behaviour as was seen in the recent [SSL/TLS bug in iOS](https://www.imperialviolet.org/2014/02/22/applebug.html).
What does "it *seems* slow" mean? Do you have benchmarks? Chances are the bottleneck isn't Python but I/O. If you need high-speed computations, there is stuff like numpy/scipy (fast C-extensions). If it's fast enough for scientific computing it's certainly good enough for general webstuff (we're comparing it to PHP anyway). If this is still not sufficient, you can just use something like pypy (a JIT-implementation), IronPython/JPython (.NET/JVM) or Cython (Python compiled to machine code).
Again I'd ask you to give a concrete example where the documentation is lacking, as I haven't had any problems with it (I learned Python through the official docs, which is hard/impossible in other languages)<|eor|><|eols|><|endoftext|> | 10 |
lolphp | captainramen | ch0oswc | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>This article misses the point. You're probably going to have to work until you are in your 60s or 70s (even more so considering that php devs are on the lower end of the payscale). Are your wrists going to last that long? Having to constantly look up shit in the docs because some part over here works slightly different from those parts over there is going to guarantee you won't make it until retirement.
And the English comparison is just nuts. Learning a language is much easier when you are young. Are you learning PHP from when you are born?<|eor|><|eols|><|endoftext|> | 9 |
lolphp | OneWingedShark | ch1ioz6 | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>> Every language has unintuitive partsPHP more than mostbut if you're an intelligent programmer, you can avoid them.
No. No, no, no. NO.
I don't have to be on the lookout for a language that is trying to make me trip and fall on every fucking step. I should have proper tools that protect me from my mistakes instead of creating traps for me to fall on.
God, I hate PHP apologists even more than I hate PHP itself.<|eor|><|sor|>>> Every language has unintuitive partsPHP more than mostbut if you're an intelligent programmer, you can avoid them.
>
>
> No. No, no, no. NO.
The sad part is that a *lot* of the pitfalls are completely avoidable.
> I don't have to be on the lookout for a language that is trying to make me trip and fall on every fucking step.
I thought the same about C while in college (I had taught myself programming using the Turbo Pascal compiler and the manuals) and it rubbed me the wrong way because I knew the gotchas in C *were* avoidable in a computer language... After graduating I went on to get employment where I was forced to use PHP, while teaching myself Ada -- and again it hit me just how much pain could be completely avoided.
> I should have proper tools that protect me from my mistakes instead of creating traps for me to fall on.
Totally agreed.
> God, I hate PHP apologists even more than I hate PHP itself.
The worst thing about them is that they refuse to even consider alternative solutions... it's almost like they completely misunderstand the implications of any computer-science theory.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | deadstone | ch0rna8 | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>> Whatever the future holds, PHP will continue to be a relevant and important language for web development.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | ALLCAPS_SWEAR_WORDS | ch11d03 | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>This article misses the point. You're probably going to have to work until you are in your 60s or 70s (even more so considering that php devs are on the lower end of the payscale). Are your wrists going to last that long? Having to constantly look up shit in the docs because some part over here works slightly different from those parts over there is going to guarantee you won't make it until retirement.
And the English comparison is just nuts. Learning a language is much easier when you are young. Are you learning PHP from when you are born?<|eor|><|sor|>lol. i know plenty of php devs making low-6-figures in the valley. among other places facebook obviously employs lots of php developers.
http://www.glassdoor.com/Salary/Facebook-Salaries-E40772.htm
<|eor|><|sor|>There's no question that you can get a job using PHP. The real question is *do you really want* a job using PHP? Plenty of people answer "yes", and to be honest, if they're a competent dev, I respect them for it. But personally, I can't.
To me, writing PHP feels like menial labor. The standard library is so gigantic and inconsistent that I constantly have to refer back to the docs (and more reliable sources) to make sure I'm using everything right. Every line of code has that lingering doubt — "Should I have used `==`, `===`, or `strcmp`? Did I accidentally use `mysql_escape_string` instead of `mysql_real_escape_string` (or some other comparable pair of functions)? Will this cast have unintended side effects? Did I put those function arguments in the right order? If there's a bug here, how long will it take to fix it?"
There's always that worry that I forgot one of the many "exceptions to the rule" in PHP, that I made some subtle mistake (like leaving out important boilerplate) that I might not even realize until months from now when a [baffling bug or exploit](http://danuxx.blogspot.com/2013/03/unauthorized-access-bypassing-php-strcmp.html) comes out of the woodwork as a result. Apparently a lot of developers can live with that, but personally I can't. I'll stick with Python and other languages, where I can generally predict what's going to happen and don't have to worry about bullshit like inconsistent function naming and poorly-done implicit type casting.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | nahguri | ch2endu | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>> Every language has unintuitive partsPHP more than mostbut if you're an intelligent programmer, you can avoid them.
No. No, no, no. NO.
I don't have to be on the lookout for a language that is trying to make me trip and fall on every fucking step. I should have proper tools that protect me from my mistakes instead of creating traps for me to fall on.
God, I hate PHP apologists even more than I hate PHP itself.<|eor|><|sor|>>> Every language has unintuitive partsPHP more than mostbut if you're an intelligent programmer, you can avoid them.
>
>
> No. No, no, no. NO.
The sad part is that a *lot* of the pitfalls are completely avoidable.
> I don't have to be on the lookout for a language that is trying to make me trip and fall on every fucking step.
I thought the same about C while in college (I had taught myself programming using the Turbo Pascal compiler and the manuals) and it rubbed me the wrong way because I knew the gotchas in C *were* avoidable in a computer language... After graduating I went on to get employment where I was forced to use PHP, while teaching myself Ada -- and again it hit me just how much pain could be completely avoided.
> I should have proper tools that protect me from my mistakes instead of creating traps for me to fall on.
Totally agreed.
> God, I hate PHP apologists even more than I hate PHP itself.
The worst thing about them is that they refuse to even consider alternative solutions... it's almost like they completely misunderstand the implications of any computer-science theory.<|eor|><|sor|>> The sad part is that a lot of the pitfalls are completely avoidable.
Of course they are! I work with PHP, I've learned to avoid most pitfalls by now. That's not a excuse, though: I shouldn't need to remember to pass TRUE as the third argument to in_array, to use array_merge instead of + because for some reason + does an associative union, to switch around the order of the arguments between array_map and array_filter, ...
> I knew the gotchas in C were avoidable in a computer language...
Well, C does have an excuse: it's old, it's low-level and it's blazing fast. Some of its "carelessness" are there by design, and at the very least they probably made sense forty years ago. PHP is relatively new, it's high level and it's so slow the measly application I work on need to run three levels of caching plus Varnish.<|eor|><|sor|>> I knew the gotchas in C were avoidable in a computer language...
>
>
> Well, C does have an excuse: it's old, it's low-level and it's blazing fast. Some of its "carelessness" are there by design, and at the very least they probably made sense forty years ago.
I rather dislike excusing C because "it's old and low-level" -- Ada 83 has some excellent low-level facilities and is [roughly] just as old. [About a decade younger if you want the "C appeared in" date, about a decade older if you want the "C standard appeared in" date.]
> PHP is relatively new, it's high level and it's so slow the measly application I work on need to run three levels of caching plus Varnish.
Ew.
>> The sad part is that a lot of the pitfalls are completely avoidable.
>
>
> I work with PHP, I've learned to avoid most pitfalls by now. That's not a excuse, though: I shouldn't need to remember to pass TRUE as the third argument to in_array, to use array_merge instead of + because for some reason + does an associative union, to switch around the order of the arguments between array_map and array_filter, ...
Oh, I fully understand, trust me.
(When I raised maintainability issues [of PHP] in my old place of employment the response was "we don't have time to do things right, we have to do them quickly." -- which indicated to me that maintenance troubles were, to them, a non-concern.)<|eor|><|sor|>> I rather dislike excusing C because "it's old and low-level"
C is like that because it's basically generalized assembly. That's just how computers work.
EDIT: PHP however is engineered this way purposefully. And that's both scary and depressing.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | knaveofspades | ch0tzzv | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>Dude actually says PHP's string functions are consistent? WTF?!?<|eor|><|sor|>You don't have to be consistent as long as your alternate names are!<|eor|><|eols|><|endoftext|> | 6 |
lolphp | EsperSpirit | ch16xax | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>If all PHP was like those examples, we wouldn't even need this subreddit.
PHP may be weird and dodgy in places, but a language like Ruby is just as horrible in its design (or even Python, which just does bad design in a different direction); the main problem with PHP is that it *encourages bad practice* and has poor documentation, as well as having provisions it shouldn't (ignoring errors == WHAT THE FUCK, WHY?!; but even things like short_open_tag are a bad idea and if they were removed, PHP would still be WTF-worthy, but at least significantly improved).<|eor|><|sor|>Can you give an example of Python doing "bad design in a different direction"?<|eor|><|sor|>Whitespace.
Possibly the fault of the code (I'm not a dev myself, just hacked stuff together in various languages when circumstances must), but it also seems slow for what it does compared to perl, and I may be looking in the wrong place, but the documentation seems very variable and I rapidly find my browser window holding half of stack overflow.<|eor|><|sor|>If you're refering to Python's use of indention instead of curly braces, this is actually better design than most languages. Python's indention never lies to you. C-like curly braces can easily hide unintended behaviour as was seen in the recent [SSL/TLS bug in iOS](https://www.imperialviolet.org/2014/02/22/applebug.html).
What does "it *seems* slow" mean? Do you have benchmarks? Chances are the bottleneck isn't Python but I/O. If you need high-speed computations, there is stuff like numpy/scipy (fast C-extensions). If it's fast enough for scientific computing it's certainly good enough for general webstuff (we're comparing it to PHP anyway). If this is still not sufficient, you can just use something like pypy (a JIT-implementation), IronPython/JPython (.NET/JVM) or Cython (Python compiled to machine code).
Again I'd ask you to give a concrete example where the documentation is lacking, as I haven't had any problems with it (I learned Python through the official docs, which is hard/impossible in other languages)<|eor|><|sor|>>Python's indention never lies to you.
Probably true if you only ever do your development in notepad, etc., but every language I've worked with has worked in vim without even needing to find syntax definitions, with missing {} etc. clearly highlighted.
As for performance, again, not my code, just that a webapp certainly takes up a lot of resources for what it does.<|eor|><|sor|>How does vim being a good editor for most languages imply Python's indention is bad design?
Of course in a perfect world everyone writes beautiful code in every language. The reality is different. Python forces you to use proper indention, which is good design.
Plus, if it makes no difference in vim, then at least it has the advantage of leaving out all the curly braces, which is a win (for me at least; some people are obsessed with curly braces for some reason)<|eor|><|eols|><|endoftext|> | 6 |
lolphp | allthediamonds | ch2h9yl | <|sols|><|sot|>/x/post from /r/programming - PHP: It doesn't have to be a bad experience<|eot|><|sol|>https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience<|eol|><|sor|>This article misses the point. You're probably going to have to work until you are in your 60s or 70s (even more so considering that php devs are on the lower end of the payscale). Are your wrists going to last that long? Having to constantly look up shit in the docs because some part over here works slightly different from those parts over there is going to guarantee you won't make it until retirement.
And the English comparison is just nuts. Learning a language is much easier when you are young. Are you learning PHP from when you are born?<|eor|><|sor|>lol. i know plenty of php devs making low-6-figures in the valley. among other places facebook obviously employs lots of php developers.
http://www.glassdoor.com/Salary/Facebook-Salaries-E40772.htm
<|eor|><|sor|>There's no question that you can get a job using PHP. The real question is *do you really want* a job using PHP? Plenty of people answer "yes", and to be honest, if they're a competent dev, I respect them for it. But personally, I can't.
To me, writing PHP feels like menial labor. The standard library is so gigantic and inconsistent that I constantly have to refer back to the docs (and more reliable sources) to make sure I'm using everything right. Every line of code has that lingering doubt — "Should I have used `==`, `===`, or `strcmp`? Did I accidentally use `mysql_escape_string` instead of `mysql_real_escape_string` (or some other comparable pair of functions)? Will this cast have unintended side effects? Did I put those function arguments in the right order? If there's a bug here, how long will it take to fix it?"
There's always that worry that I forgot one of the many "exceptions to the rule" in PHP, that I made some subtle mistake (like leaving out important boilerplate) that I might not even realize until months from now when a [baffling bug or exploit](http://danuxx.blogspot.com/2013/03/unauthorized-access-bypassing-php-strcmp.html) comes out of the woodwork as a result. Apparently a lot of developers can live with that, but personally I can't. I'll stick with Python and other languages, where I can generally predict what's going to happen and don't have to worry about bullshit like inconsistent function naming and poorly-done implicit type casting.<|eor|><|sor|>Yeah, I hear you.
It's almost as bad as writing javascript.<|eor|><|sor|>JavaScript actually has a decent oo model and not global function hell.<|eor|><|sor|>Javascript doesn't have actual objects. No private, protected. No interfaces. Give javascript credit for what it does well but it's OO model is atrocious. <|eor|><|sor|>Javascript has a completely different object model to that of Java/C#/PHP/etc. It's broken, yes, not by being different, but by not being a correct implementation of the object model it aims to be.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | vytah | 12r1mg | <|sols|><|sot|>Guess the output: var_dump(Datetime::createFromFormat('u', '015700')->format('u'));<|eot|><|sol|>https://bugs.php.net/bug.php?id=63435<|eol|><|eols|><|endoftext|> | 21 |
lolphp | vytah | c6xhc6e | <|sols|><|sot|>Guess the output: var_dump(Datetime::createFromFormat('u', '015700')->format('u'));<|eot|><|sol|>https://bugs.php.net/bug.php?id=63435<|eol|><|sor|>This is actually a lolc, really.<|eor|><|soopr|>It's not C, it's PHP devs' choice to use double for storing time:
> Datetime objects hold microseconds as "double" type in C.
Storing nanoseconds in uint32_t would be more compact and more accurate.<|eoopr|><|eols|><|endoftext|> | 10 |
lolphp | sloat | c6xns2r | <|sols|><|sot|>Guess the output: var_dump(Datetime::createFromFormat('u', '015700')->format('u'));<|eot|><|sol|>https://bugs.php.net/bug.php?id=63435<|eol|><|sor|>Waiting for the obligatory, "not a bug" comment from the php core team.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | vytah | c6xpqhq | <|sols|><|sot|>Guess the output: var_dump(Datetime::createFromFormat('u', '015700')->format('u'));<|eot|><|sol|>https://bugs.php.net/bug.php?id=63435<|eol|><|sor|>Guess storing numbers in strings is just standard practice in PHP?<|eor|><|sor|>The `double` problem pops up occasionally in other places, but yeah, `int`s in PHP should probably be used for numbers `-1000 < x <1000` or so.
[Remeber to use `===` and `!==` when comparing "number strings".](http://phpsadness.com/sad/47).
Arguably, you should never use `==` and `!=` at all, but I'm totally guilty of this.<|eor|><|sor|>Yeah but you can't hold it against PHP. It's a limitation of the computer. They don't have just unlimited bits. I bet they only have 10 bit range left (`1 << 9 == 1024` plus a sign bit) because their object header is 22 bits. If you have a 64 bit computer you can have bigger numbers!<|eor|><|sor|>first of `double`s are 64-bits (2 * 32 = 64), and 64bit computers don't have a quadruple type, the problem is using a floating-point type to store an integer.
my w/i 1000 was totally non-scientific and not based on anything (this is reddit after all) The actualy maximum is quite a bit higher, from what I remember PHP is semi-smart about this. integers that can be represented as a signed 32-bit integer are, numbers greater than or less than that are represented by a double. (could be wrong) This can cause some *very* strange behaviour in edge cases.
Compare this with Python which will "upgrade" an int (32bit) to long (64bit) on an integer overflow, when a long overflows it throws an exception. (Python also doesn't have coercive comparison operators, but that's another story)
Edit: CS201 (systems programming) is coming back in fits & starts.
A double is capable of storing a 32-bit integer w/o data loss, so PHP probably isn't converting the int to a double. (I code in Python too much to remember my C very well)<|eor|><|soopr|>Python 2's long is not 64 bit, it's a bigint.<|eoopr|><|eols|><|endoftext|> | 5 |
lolphp | ptrin | z11cf | <|sols|><|sot|>Note that elseif and else if will only be considered exactly the same when using curly brackets as in the above example. When using a colon to define your if/elseif conditions, you must not separate else if into two words, or PHP will fail with a parse error.<|eot|><|sol|>http://php.net/manual/en/control-structures.elseif.php<|eol|><|eols|><|endoftext|> | 22 |
lolphp | kingguru | c60kc8i | <|sols|><|sot|>Note that elseif and else if will only be considered exactly the same when using curly brackets as in the above example. When using a colon to define your if/elseif conditions, you must not separate else if into two words, or PHP will fail with a parse error.<|eot|><|sol|>http://php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>Golden comment:
>Note that } elseif() { is somewhat faster than } else if() {
> ...
> ===================================
>Result (depending on hardware configuration):
>
>1: 20.026723146439
>
>2: 20.20437502861
Edit: fixed formatting<|eor|><|eols|><|endoftext|> | 12 |
lolphp | kingguru | c60lqdh | <|sols|><|sot|>Note that elseif and else if will only be considered exactly the same when using curly brackets as in the above example. When using a colon to define your if/elseif conditions, you must not separate else if into two words, or PHP will fail with a parse error.<|eot|><|sol|>http://php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>Golden comment:
>Note that } elseif() { is somewhat faster than } else if() {
> ...
> ===================================
>Result (depending on hardware configuration):
>
>1: 20.026723146439
>
>2: 20.20437502861
Edit: fixed formatting<|eor|><|sor|>Is it re-parsing the loop with every execution?<|eor|><|sor|>Nah, that's not really the problem. Thanks to prtin for posting this link, because it really is a good example of what is wrong with PHP.
Time to rant and I would hope this is a good place for that :-)
The only difference between **elseif** and **else if** seems to be that you get a parse error if you **else if** instead of **elseif** in a conditional statement starting with **if**.
That smells like an extremely broken parser, where there's no reason why there should be any difference. Might be because no one really knows how the code is working and that no one really knows how to write a parser in the first place.
If you think it would cool be to be able to write **elseif** instead of **else if** for no obvious reason, make sure they at least behave the same way. Anything else will just be confusing to anyone writing code in the language.
The comment to the documentation was funny, because no one who knows just a bit about how to implement a programming language (and I am very far from being an expert in that field) would ever consider benchmarking language constructs that should basically do the same thing. It definitely didn't make it less funny that the benchmark was totally useless.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | Jinxuan | ekz4vd | <|soss|><|sot|>in_array can return True, False and just simply fail.<|eot|><|sost|>The feature is provided by the default usage of `==` in in\_array.
For example,
```
$a = new stdClass;
$b = in_array($a, [0, $a]); // PHP Notice: Object of class stdClass could not be converted to int
```
$b is not assigned, because `==` comparison in PHP can fail without callback...<|eost|><|eoss|><|endoftext|> | 21 |
lolphp | barubary | fdewthp | <|soss|><|sot|>in_array can return True, False and just simply fail.<|eot|><|sost|>The feature is provided by the default usage of `==` in in\_array.
For example,
```
$a = new stdClass;
$b = in_array($a, [0, $a]); // PHP Notice: Object of class stdClass could not be converted to int
```
$b is not assigned, because `==` comparison in PHP can fail without callback...<|eost|><|sor|>> $b is not assigned
[citation needed]<|eor|><|eoss|><|endoftext|> | 25 |
lolphp | maxgee | fdeuvgi | <|soss|><|sot|>in_array can return True, False and just simply fail.<|eot|><|sost|>The feature is provided by the default usage of `==` in in\_array.
For example,
```
$a = new stdClass;
$b = in_array($a, [0, $a]); // PHP Notice: Object of class stdClass could not be converted to int
```
$b is not assigned, because `==` comparison in PHP can fail without callback...<|eost|><|sor|>It appears to still set $b regardless of throwing a notice. https://3v4l.org/SplCf
Also, if you turn on strict comparison (which you should be using), it works just fine without a notice: https://3v4l.org/ttE98<|eor|><|eoss|><|endoftext|> | 17 |
lolphp | morphotomy | fdfbocf | <|soss|><|sot|>in_array can return True, False and just simply fail.<|eot|><|sost|>The feature is provided by the default usage of `==` in in\_array.
For example,
```
$a = new stdClass;
$b = in_array($a, [0, $a]); // PHP Notice: Object of class stdClass could not be converted to int
```
$b is not assigned, because `==` comparison in PHP can fail without callback...<|eost|><|sor|>This is why all my code dies on E_NOTICE.<|eor|><|eoss|><|endoftext|> | 9 |
lolphp | Takeoded | al3e8s | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|eols|><|endoftext|> | 17 |
lolphp | scatters | efadd97 | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|sor|>Y'see, `$o->foo` (without trailing parentheses) is a reference to a member variable. The right way to spell a reference to a bound method is `[$o, 'foo']`. https://3v4l.org/FsWED<|eor|><|eols|><|endoftext|> | 34 |
lolphp | mikeputerbaugh | efbohwk | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|sor|>Y'see, `$o->foo` (without trailing parentheses) is a reference to a member variable. The right way to spell a reference to a bound method is `[$o, 'foo']`. https://3v4l.org/FsWED<|eor|><|sor|>That might be the successful way, but it's not _right_.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | iopq | efb9zn9 | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|sor|>Y'see, `$o->foo` (without trailing parentheses) is a reference to a member variable. The right way to spell a reference to a bound method is `[$o, 'foo']`. https://3v4l.org/FsWED<|eor|><|sor|>Jesus Christ, how horrifying<|eor|><|eols|><|endoftext|> | 13 |
lolphp | vita10gy | efabul5 | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|sor|>This feels more like tricking PHP with dumbassery than a true LOLPHP.
You've created a situation where neither answer to is_callable($o->foo) is right.
I'd guess you're arguing it should error and not allow instance variables and functions to have the same name?
Edit: Looks like you want an error. I suppose that's possible, but, eh. <|eor|><|eols|><|endoftext|> | 12 |
lolphp | CliffEdgeOrg | efcm0c3 | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|sor|>this is not lolphp, this is lolOP for not even bothering to understand what is the difference between a property and a method.
​
I'm gonna blow your mind: [https://3v4l.org/ma2fi](https://3v4l.org/ma2fi)<|eor|><|eols|><|endoftext|> | 11 |
lolphp | duskwuff | efaktqu | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|soopr|>(for the record, i would have expected a compile-time error, not whatever the *** it's actually doing here)<|eoopr|><|sor|>Why would you expect a compile-time error? `is_callable()` is a function which takes a single argument. `$o->foo` is an expression which, in this case, evaluates to the number 5. `is_callable(5)` is false.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | joske79 | efea883 | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|sor|>Works 100% as expected. You're checking if value 5 is callable; which ofcourse isn't.
Try this: https://3v4l.org/3s0uWo<|eor|><|eols|><|endoftext|> | 5 |
lolphp | shitcanz | efi8pwr | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|sor|>This is why PHP has such a bad rep. Its a clusterfuck of badly implemented thin wrapper functions around C that dont really mix well with the rest of the "language".
Eg. heres how python handles this case: https://repl.it/repls/PoshSweetHarddrives
Simple, and predictable.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | jesseschalken | efbv89n | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|sor|>[deleted]<|eor|><|sor|>Java is the same (methods and fields can have the same name and are distinguished by syntax) so I guess that's where it came from, along with the rest of PHP's object model.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | dotancohen | efpr2gc | <|sols|><|sot|>is_callable "verify that the contents of a variable can be called as a function" - except when it doesn't.<|eot|><|sol|>https://3v4l.org/aPX8b<|eol|><|sor|>Y'see, `$o->foo` (without trailing parentheses) is a reference to a member variable. The right way to spell a reference to a bound method is `[$o, 'foo']`. https://3v4l.org/FsWED<|eor|><|sor|>I hate this syntax with PHP but a lot of OOP languages have this kind of problem with bound functions.
The issue being:
class Foo {
function bar() {};
}
is usually syntactic sugar for
class Foo {};
function bar(Foo $this) {};
This screws up higher-order functions which expect to take a function with a syntax of `void(void)`.
Most solutions also aren't satisfying, either.<|eor|><|sor|>I often find myself divided on whether or not Python got this right.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Takeoded | a881yt | <|soss|><|sot|>let's play a little game with FILTER_VALIDATE_DOMAIN<|eot|><|sost|>FILTER_VALIDATE_DOMAIN returns bool(false) when it thinks the input isn't a domain. so what is a valid domain?
"" -> valid
"example.org/wat" -> valid
"DOG!" -> valid!
" " -> valid!
what else? test code here: https://3v4l.org/aGe63
^^^^^^\( ^^^^^^and ^^^^^^a ^^^^^^related ^^^^^^bugreport ^^^^^^here: ^^^^^^https://bugs.php.net/bug.php?id=77331 ^^^^^^)<|eost|><|eoss|><|endoftext|> | 21 |
lolphp | AyrA_ch | ecalq5o | <|soss|><|sot|>let's play a little game with FILTER_VALIDATE_DOMAIN<|eot|><|sost|>FILTER_VALIDATE_DOMAIN returns bool(false) when it thinks the input isn't a domain. so what is a valid domain?
"" -> valid
"example.org/wat" -> valid
"DOG!" -> valid!
" " -> valid!
what else? test code here: https://3v4l.org/aGe63
^^^^^^\( ^^^^^^and ^^^^^^a ^^^^^^related ^^^^^^bugreport ^^^^^^here: ^^^^^^https://bugs.php.net/bug.php?id=77331 ^^^^^^)<|eost|><|sor|>You forgot to supply `FILTER_FLAG_HOSTNAME`
Domain name is not the same as a host name and can contain symbols which conflict with other. Tell it to filter the hostname properly and you can validate emoji domains too:
echo filter_var(idn_to_ascii(".com",0,INTL_IDNA_VARIANT_UTS46),FILTER_VALIDATE_DOMAIN,FILTER_FLAG_HOSTNAME);
I would not be surprised if an empty domain name is valid because it likely references the top level domain<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | AyrA_ch | ecbk0cb | <|soss|><|sot|>let's play a little game with FILTER_VALIDATE_DOMAIN<|eot|><|sost|>FILTER_VALIDATE_DOMAIN returns bool(false) when it thinks the input isn't a domain. so what is a valid domain?
"" -> valid
"example.org/wat" -> valid
"DOG!" -> valid!
" " -> valid!
what else? test code here: https://3v4l.org/aGe63
^^^^^^\( ^^^^^^and ^^^^^^a ^^^^^^related ^^^^^^bugreport ^^^^^^here: ^^^^^^https://bugs.php.net/bug.php?id=77331 ^^^^^^)<|eost|><|sor|>You forgot to supply `FILTER_FLAG_HOSTNAME`
Domain name is not the same as a host name and can contain symbols which conflict with other. Tell it to filter the hostname properly and you can validate emoji domains too:
echo filter_var(idn_to_ascii(".com",0,INTL_IDNA_VARIANT_UTS46),FILTER_VALIDATE_DOMAIN,FILTER_FLAG_HOSTNAME);
I would not be surprised if an empty domain name is valid because it likely references the top level domain<|eor|><|sor|>Unless you want to point to the RFC that says otherwise, I doubt whitespace is a valid domain name for any kind of record. So yeah, even validation functions in PHP pull random behavior out of their cracks when handed invalid input.<|eor|><|sor|>> Unless you want to point to the RFC that says otherwise, I doubt whitespace is a valid domain name.
Whitespace at the beginning and end is stripped:
nslookup " cable.ayra.ch "
Server: UnKnown
Address: 192.168.1.1
Non-authoritative answer:
Name: cable.ayra.ch
Address: 46.140.111.92
Therefore it's an empty string, which is the root namespace in an FQDN:
> The DNS root is unnamed, expressed as the empty label terminated by the dot. This is most notable in DNS zone files in which a fully qualified domain name must be specified with a trailing dot. For example, *somehost.example.com.* explicitly specifies an absolute domain name that ends with the empty top level domain label.
[Source](https://en.wikipedia.org/wiki/Fully_qualified_domain_name#Syntax)
Unless you configure DNS resolvers, you likely never entered the last dot in a domain name because a DNS client adds it to your query.
Accessing domains like [cable.ayra.ch.](https://cable.ayra.ch./) works with the trailing dot. All common browsers will leave said dot in the address bar. IE 11 fails to validate the certificate however<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | AyrA_ch | ecboifh | <|soss|><|sot|>let's play a little game with FILTER_VALIDATE_DOMAIN<|eot|><|sost|>FILTER_VALIDATE_DOMAIN returns bool(false) when it thinks the input isn't a domain. so what is a valid domain?
"" -> valid
"example.org/wat" -> valid
"DOG!" -> valid!
" " -> valid!
what else? test code here: https://3v4l.org/aGe63
^^^^^^\( ^^^^^^and ^^^^^^a ^^^^^^related ^^^^^^bugreport ^^^^^^here: ^^^^^^https://bugs.php.net/bug.php?id=77331 ^^^^^^)<|eost|><|sor|>You forgot to supply `FILTER_FLAG_HOSTNAME`
Domain name is not the same as a host name and can contain symbols which conflict with other. Tell it to filter the hostname properly and you can validate emoji domains too:
echo filter_var(idn_to_ascii(".com",0,INTL_IDNA_VARIANT_UTS46),FILTER_VALIDATE_DOMAIN,FILTER_FLAG_HOSTNAME);
I would not be surprised if an empty domain name is valid because it likely references the top level domain<|eor|><|sor|>Unless you want to point to the RFC that says otherwise, I doubt whitespace is a valid domain name for any kind of record. So yeah, even validation functions in PHP pull random behavior out of their cracks when handed invalid input.<|eor|><|sor|>> Unless you want to point to the RFC that says otherwise, I doubt whitespace is a valid domain name.
Whitespace at the beginning and end is stripped:
nslookup " cable.ayra.ch "
Server: UnKnown
Address: 192.168.1.1
Non-authoritative answer:
Name: cable.ayra.ch
Address: 46.140.111.92
Therefore it's an empty string, which is the root namespace in an FQDN:
> The DNS root is unnamed, expressed as the empty label terminated by the dot. This is most notable in DNS zone files in which a fully qualified domain name must be specified with a trailing dot. For example, *somehost.example.com.* explicitly specifies an absolute domain name that ends with the empty top level domain label.
[Source](https://en.wikipedia.org/wiki/Fully_qualified_domain_name#Syntax)
Unless you configure DNS resolvers, you likely never entered the last dot in a domain name because a DNS client adds it to your query.
Accessing domains like [cable.ayra.ch.](https://cable.ayra.ch./) works with the trailing dot. All common browsers will leave said dot in the address bar. IE 11 fails to validate the certificate however<|eor|><|sor|>I'm not sure `nslookup` is exactly what should be determining valid input, as opposed to, oh, `gethostbyname`. It's PHP tweaking the input values in what is supposed to be a validation function.<|eor|><|sor|>gethostbyname can't resolve the root zone either. Calling it on an empty string returns the current host address, which is consistent with at least the Windows Domain API<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | Partonetrain | 9jze2l | <|sols|><|sot|>A long-winded apology comment<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/9jx3vz/im_getting_second_thoughts_about_whether/?st=JMNS0O56&sh=c2063274<|eol|><|eols|><|endoftext|> | 18 |
lolphp | cleeder | e6wwh3y | <|sols|><|sot|>A long-winded apology comment<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/9jx3vz/im_getting_second_thoughts_about_whether/?st=JMNS0O56&sh=c2063274<|eol|><|sor|>Stolen from r/programmerhumor<|eor|><|sor|>It's hardly stolen. The link is literally _to_ /r/ProgrammerHumor <|eor|><|eols|><|endoftext|> | 9 |
lolphp | Partonetrain | e6v718p | <|sols|><|sot|>A long-winded apology comment<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/9jx3vz/im_getting_second_thoughts_about_whether/?st=JMNS0O56&sh=c2063274<|eol|><|soopr|>Perhaps more about the fault of the author then the language, but still funny.<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | nuephelkystikon | e6v7k1r | <|sols|><|sot|>A long-winded apology comment<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/9jx3vz/im_getting_second_thoughts_about_whether/?st=JMNS0O56&sh=c2063274<|eol|><|soopr|>Perhaps more about the fault of the author then the language, but still funny.<|eoopr|><|sor|>Two nails in the same coffin. *My* coffin. <|eor|><|eols|><|endoftext|> | 8 |
lolphp | nyamsprod | 67n509 | <|sols|><|sot|>is this a bug or expected behaviour for substr<|eot|><|sol|>https://3v4l.org/JcYmO<|eol|><|eols|><|endoftext|> | 19 |
lolphp | arnoutboks | dgrppwd | <|sols|><|sot|>is this a bug or expected behaviour for substr<|eot|><|sol|>https://3v4l.org/JcYmO<|eol|><|sor|>Although it remains strange, this is documented behavior:
* The first expression returning false is documented in the parameter description for the start-parameter: http://php.net/manual/en/function.substr.php#refsect1-function.substr-parameters
* The second expression starting at the end of the string is documented in the changelog (http://php.net/manual/en/function.substr.php#refsect1-function.substr-changelog). This behavior was different for PHP 5.2.2 - 5.2.6, which you can also observe by turning on 'EOL versions' in your 3v4l.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | implicit_cast | 2lwogw | <|sols|><|sot|>Reference arguments can retarget $this<|eot|><|sol|>http://3v4l.org/mtkR4<|eol|><|eols|><|endoftext|> | 19 |
lolphp | Lokaltog | clz7xz5 | <|sols|><|sot|>Reference arguments can retarget $this<|eot|><|sol|>http://3v4l.org/mtkR4<|eol|><|sor|>I expanded OP's example a bit, it appears that this would have been a much bigger issue in PHP <5: http://3v4l.org/mFSeh
In PHP >5 it seems $this is only overwritten in the function scope and not globally, making this a bit less lolphp than I initially thought reading OP's source code.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | Sarcastinator | clz8ojy | <|sols|><|sot|>Reference arguments can retarget $this<|eot|><|sol|>http://3v4l.org/mtkR4<|eol|><|sor|>What's the lol? It's doing exactly what it is being told to do. If in another language you passed the address of 'this' to some other function which then clobbered the data at that address... what exactly do you expect to happen?
$this isn't going to be sacred if you go passing it's reference around and then doing stupid shit to that reference. You aren't dealing with $this anymore at that point and are just fucking with mystery data in stupid ways that you know you shouldn't be doing.
Now tell me all the ways that I'm wrong and stupid. Come at me sub!<|eor|><|sor|>C# does not allow it. You cannot pass `this` to `ref` or `out` parameters (the error message is 'out/ref argument is not classified as a variable'), and taking the address of `this` is illegal.
In C++ `this` is defined as a `const`, and cannot be passed to a non-const ref parameter without casting but at that point the caller is just as responsible as the callee.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | Lokaltog | clz726u | <|sols|><|sot|>Reference arguments can retarget $this<|eot|><|sol|>http://3v4l.org/mtkR4<|eol|><|sor|>What's the lol? It's doing exactly what it is being told to do. If in another language you passed the address of 'this' to some other function which then clobbered the data at that address... what exactly do you expect to happen?
$this isn't going to be sacred if you go passing it's reference around and then doing stupid shit to that reference. You aren't dealing with $this anymore at that point and are just fucking with mystery data in stupid ways that you know you shouldn't be doing.
Now tell me all the ways that I'm wrong and stupid. Come at me sub!<|eor|><|sor|>I agree. But it should be mentioned that several examples have been posted in this sub where core PHP code manipulates object references unexpectedly, so I kinda get why a feature like this can be seen as scary (or even a bug) when it's a part of an unstructured, unpredictable language like PHP.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | implicit_cast | clzgo3q | <|sols|><|sot|>Reference arguments can retarget $this<|eot|><|sol|>http://3v4l.org/mtkR4<|eol|><|sor|>What's the lol? It's doing exactly what it is being told to do. If in another language you passed the address of 'this' to some other function which then clobbered the data at that address... what exactly do you expect to happen?
$this isn't going to be sacred if you go passing it's reference around and then doing stupid shit to that reference. You aren't dealing with $this anymore at that point and are just fucking with mystery data in stupid ways that you know you shouldn't be doing.
Now tell me all the ways that I'm wrong and stupid. Come at me sub!<|eor|><|sor|>I agree. But it should be mentioned that several examples have been posted in this sub where core PHP code manipulates object references unexpectedly, so I kinda get why a feature like this can be seen as scary (or even a bug) when it's a part of an unstructured, unpredictable language like PHP.<|eor|><|sor|>I look at this and what I see is a contortionist being asked to squeek out a biscuit while her legs are flopped backwards over her head. And then people come along like "lol contortionists" as though it's unexpected that a pile of poop will land on her head in that position.
What... what exactly do people really expect to happen? I just don't get most of the lol crowd at all. Clearly we are past the point of critiquing actual issues and are just engineering silly situations where things have no choice but to go wrong. I sub here in case something comes-up that I might learn from and be aware of that I otherwise wouldn't have, but most of the time it's just nonsense.<|eor|><|soopr|>It's just another example of astonishingly bad taste on the part of the PHP designers, really.
I posted it because it's the root cause of an actual bug I spent actual time investigating. At the time, I was expecting the root cause to be memory corruption in the PHP interpreter.
The original author was not particularly stupid. I think the code had to run on PHP4 when it was originally written.<|eoopr|><|eols|><|endoftext|> | 5 |
lolphp | implicit_cast | clzlg5u | <|sols|><|sot|>Reference arguments can retarget $this<|eot|><|sol|>http://3v4l.org/mtkR4<|eol|><|sor|>What's the lol? It's doing exactly what it is being told to do. If in another language you passed the address of 'this' to some other function which then clobbered the data at that address... what exactly do you expect to happen?
$this isn't going to be sacred if you go passing it's reference around and then doing stupid shit to that reference. You aren't dealing with $this anymore at that point and are just fucking with mystery data in stupid ways that you know you shouldn't be doing.
Now tell me all the ways that I'm wrong and stupid. Come at me sub!<|eor|><|sor|>I agree. But it should be mentioned that several examples have been posted in this sub where core PHP code manipulates object references unexpectedly, so I kinda get why a feature like this can be seen as scary (or even a bug) when it's a part of an unstructured, unpredictable language like PHP.<|eor|><|sor|>I look at this and what I see is a contortionist being asked to squeek out a biscuit while her legs are flopped backwards over her head. And then people come along like "lol contortionists" as though it's unexpected that a pile of poop will land on her head in that position.
What... what exactly do people really expect to happen? I just don't get most of the lol crowd at all. Clearly we are past the point of critiquing actual issues and are just engineering silly situations where things have no choice but to go wrong. I sub here in case something comes-up that I might learn from and be aware of that I otherwise wouldn't have, but most of the time it's just nonsense.<|eor|><|soopr|>It's just another example of astonishingly bad taste on the part of the PHP designers, really.
I posted it because it's the root cause of an actual bug I spent actual time investigating. At the time, I was expecting the root cause to be memory corruption in the PHP interpreter.
The original author was not particularly stupid. I think the code had to run on PHP4 when it was originally written.<|eoopr|><|sor|>I don't see how it's bad taste when it's probably simply an oversight to not restrict that type of operation. But then what's the point anyway when you have things like variable variables and you can probably find a loophole elsewhere like that, in which case there's another area that would again need to be locked-down further. All you end-up with is a set of extra restrictions which go against the rest of the general nature of PHP. You can't have your cake and eat it too, or have your PHP and not have it behave like PHP.
PHP isn't C. People want it to be all locked-down and perfect, but the loose nature of it all means weird cases like this are possible. You have to take the good with the bad.<|eor|><|soopr|>PHP references are badly designed. Almost all uses of them are fraught with inadvertent spooky action at a distance. By tolerating them as part of the language, the PHP developers demonstrate astonishingly bad taste.
You do not "have to take the bad with the good." You can point out cases where PHP is stupid and advocate that the language be changed, or you can dump PHP and use something else.
<|eoopr|><|eols|><|endoftext|> | 5 |
lolphp | frezik | 1zmnx6 | <|sols|><|sot|>Language Community Litmus Test: Database Placeholders<|eot|><|sol|>http://www.wumpus-cave.net/2014/03/04/language-community-litmus-test-database-placeholders/<|eol|><|eols|><|endoftext|> | 18 |
lolphp | deadstone | cfv36oi | <|sols|><|sot|>Language Community Litmus Test: Database Placeholders<|eot|><|sol|>http://www.wumpus-cave.net/2014/03/04/language-community-litmus-test-database-placeholders/<|eol|><|sor|>MY EYES<|eor|><|eols|><|endoftext|> | 7 |
lolphp | iopq | cfvghxm | <|sols|><|sot|>Language Community Litmus Test: Database Placeholders<|eot|><|sol|>http://www.wumpus-cave.net/2014/03/04/language-community-litmus-test-database-placeholders/<|eol|><|sor|>Node doesn't have prepared statements, it's actually kind of embarrassing.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Jonny_Axehandle | zxhlr | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|eols|><|endoftext|> | 20 |
lolphp | ismtrn | c68mq5z | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>TIL: There is no limit to what you can achieve with PHP.
<|eor|><|sor|>http://www.zombo.com/
You can do anything at zombo.com, anything at all.<|eor|><|eols|><|endoftext|> | 22 |
lolphp | krinndnz | c68poiw | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>I can't decide if that's ESL English or Freshman In A Great Hurry To Turn Anything At All In English.
Alternatively, it could be just taking a bunch of PHP-boosterism articles and exquisite-corpsing them together. It has a bit of that flavor to it. <|eor|><|eols|><|endoftext|> | 14 |
lolphp | duskwuff | c68sqls | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>I can't decide if that's ESL English or Freshman In A Great Hurry To Turn Anything At All In English.
Alternatively, it could be just taking a bunch of PHP-boosterism articles and exquisite-corpsing them together. It has a bit of that flavor to it. <|eor|><|sor|>I'm guessing underpaid contract writer.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | MonkeeSage | c68w69g | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>Oh, come on, you can find stupid articles about *any* programming language.<|eor|><|sor|> 1. Not usually on the dev blog of a company selling product support.
2. Articles on "Why X is Efficient and Popular Scripting Language" usually contain at least some kind of reasoning explaining that fact, rather than just a vague list of basic features (which are not even unique to language X).<|eor|><|eols|><|endoftext|> | 9 |
lolphp | blueskin | c6bsivk | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>>Any changes that are made to the source code can be saved and employed for commercial purposes without any legal drawbacks.
http://i.imgur.com/I0uzn.jpg<|eor|><|eols|><|endoftext|> | 8 |
lolphp | blueskin | c68vzn5 | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>That post says IIS supports PHP, which leads me to the question: has anyone actually managed this? It sounds like it would be *incredibly* painful.<|eor|><|sor|>Isn't IIS painful in general?
IIS Isn't Secure.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | escozzia | c68mu10 | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>That post says IIS supports PHP, which leads me to the question: has anyone actually managed this? It sounds like it would be *incredibly* painful.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | rossryan | c68kg7t | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>Ow ow ow ow my head ow fuck why did I try to read that<|eor|><|sor|>Because you have masochistic tendencies. It could be worse -> you could be reading the PHP documentation itself. <|eor|><|eols|><|endoftext|> | 6 |
lolphp | Krenair | c68nydg | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>That post says IIS supports PHP, which leads me to the question: has anyone actually managed this? It sounds like it would be *incredibly* painful.<|eor|><|sor|>Yes, it's possible. Google it.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | fazzah | c6yqut2 | <|sols|><|sot|>Why PHP is Efficient and Popular Scripting Language<|eot|><|sol|>http://www.blog.joomla-developers.com/why-php-is-efficient-and-popular-scripting-language/<|eol|><|sor|>> Attractive section of content. I just stumbled upon your weblog and in accession capital to assert that I acquire in fact enjoyed account your blog posts. Anyway I will be subscribing to your feeds and even I achievement you access consistently quickly.
Spoken most descriptively and with utmost accuracy regarding the content of the submitted blog post<|eor|><|sor|>ehm, it's a bot, see his username.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Porges | vcvpv | <|sols|><|sot|>function f(){return f();} segfaults, no error message - "not a bug"
<|eot|><|sol|>https://bugs.php.net/bug.php?id=28687<|eol|><|eols|><|endoftext|> | 19 |
lolphp | Rhomboid | c53du76 | <|sols|><|sot|>function f(){return f();} segfaults, no error message - "not a bug"
<|eot|><|sol|>https://bugs.php.net/bug.php?id=28687<|eol|><|sor|>Well, in this case they're right. Infinite recursion is not a bug in the language. And it generates a segfault in many languages, for example C:
$ gcc -xc -<<<'int main() { return main(); }' && ./a.out
Segmentation fault
In Perl the program simply consumes all memory until it's killed by the OS:
$ perl -e 'sub foo { return foo() } foo();'
Killed
Ruby does at least raise a SystemStackError:
$ ruby -e 'def foo; foo; end; foo'
-e:1:in `foo': stack level too deep (SystemStackError)
from -e:1:in `foo'
from -e:1
As does Python, after printing a gigantic stack trace of all 200 frames:
$ python -c 'foo = lambda: foo(); foo()' |& tail -n1
RuntimeError: maximum recursion depth exceeded
Perhaps a segmentation fault isn't the most graceful way to terminate, but it's not entirely out of line.
<|eor|><|eols|><|endoftext|> | 24 |
lolphp | FlyingBishop | c53f1bk | <|sols|><|sot|>function f(){return f();} segfaults, no error message - "not a bug"
<|eot|><|sol|>https://bugs.php.net/bug.php?id=28687<|eol|><|sor|>Well, in this case they're right. Infinite recursion is not a bug in the language. And it generates a segfault in many languages, for example C:
$ gcc -xc -<<<'int main() { return main(); }' && ./a.out
Segmentation fault
In Perl the program simply consumes all memory until it's killed by the OS:
$ perl -e 'sub foo { return foo() } foo();'
Killed
Ruby does at least raise a SystemStackError:
$ ruby -e 'def foo; foo; end; foo'
-e:1:in `foo': stack level too deep (SystemStackError)
from -e:1:in `foo'
from -e:1
As does Python, after printing a gigantic stack trace of all 200 frames:
$ python -c 'foo = lambda: foo(); foo()' |& tail -n1
RuntimeError: maximum recursion depth exceeded
Perhaps a segmentation fault isn't the most graceful way to terminate, but it's not entirely out of line.
<|eor|><|sor|>[deleted]<|eor|><|sor|>> a managed language like PHP
See, now that's where you're making one too many assumptions.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | zvxr | c53ghij | <|sols|><|sot|>function f(){return f();} segfaults, no error message - "not a bug"
<|eot|><|sol|>https://bugs.php.net/bug.php?id=28687<|eol|><|sor|>Well, in this case they're right. Infinite recursion is not a bug in the language. And it generates a segfault in many languages, for example C:
$ gcc -xc -<<<'int main() { return main(); }' && ./a.out
Segmentation fault
In Perl the program simply consumes all memory until it's killed by the OS:
$ perl -e 'sub foo { return foo() } foo();'
Killed
Ruby does at least raise a SystemStackError:
$ ruby -e 'def foo; foo; end; foo'
-e:1:in `foo': stack level too deep (SystemStackError)
from -e:1:in `foo'
from -e:1
As does Python, after printing a gigantic stack trace of all 200 frames:
$ python -c 'foo = lambda: foo(); foo()' |& tail -n1
RuntimeError: maximum recursion depth exceeded
Perhaps a segmentation fault isn't the most graceful way to terminate, but it's not entirely out of line.
<|eor|><|sor|> $ echo main = main > loop.hs
$ ghc loop.hs
$ ./loop
loop: <<loop>>
How a *civilised* programming language and compiler will deal with it.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | ealf | c53lsh1 | <|sols|><|sot|>function f(){return f();} segfaults, no error message - "not a bug"
<|eot|><|sol|>https://bugs.php.net/bug.php?id=28687<|eol|><|sor|>[My favorite way to trigger this bug with a single typo](http://www.reddit.com/r/lolphp/comments/f91wt/segfault_the_interpreter_with_a_typo/):
class Foo {
var $name;
public function __toString() {
return $this>name;
}
}
<|eor|><|eols|><|endoftext|> | 14 |
lolphp | Porges | c53e4t7 | <|sols|><|sot|>function f(){return f();} segfaults, no error message - "not a bug"
<|eot|><|sol|>https://bugs.php.net/bug.php?id=28687<|eol|><|sor|>Well, in this case they're right. Infinite recursion is not a bug in the language. And it generates a segfault in many languages, for example C:
$ gcc -xc -<<<'int main() { return main(); }' && ./a.out
Segmentation fault
In Perl the program simply consumes all memory until it's killed by the OS:
$ perl -e 'sub foo { return foo() } foo();'
Killed
Ruby does at least raise a SystemStackError:
$ ruby -e 'def foo; foo; end; foo'
-e:1:in `foo': stack level too deep (SystemStackError)
from -e:1:in `foo'
from -e:1
As does Python, after printing a gigantic stack trace of all 200 frames:
$ python -c 'foo = lambda: foo(); foo()' |& tail -n1
RuntimeError: maximum recursion depth exceeded
Perhaps a segmentation fault isn't the most graceful way to terminate, but it's not entirely out of line.
<|eor|><|sor|>[deleted]<|eor|><|soopr|>... and I think the 3 non-C examples show that PHP is incorrect here.
A stack overflow message or memory exhaustion are to be expected, but for your managed runtime to die with no error isn't cool. The 3 non-C examples are all sane behaviour. <|eoopr|><|eols|><|endoftext|> | 10 |
lolphp | adrenal8 | ppy9v | <|sols|><|sot|>PHP's case sensitivity inconsistencies<|eot|><|sol|>http://the-echoplex.net/log/php-case-sensitivity<|eol|><|eols|><|endoftext|> | 19 |
lolphp | HawtDawgH20 | p65d1t | <|soss|><|sot|>Product Manager seeking recommendations on static code performance optimizers.<|eot|><|sost|>Hi Everyone.
I am looking for a recommendation on a static PHP code analyzer for performance. I came from a Java background, so I am new to the PHP community. I am looking for a tool for a sniff test to determine if we need to consult outside resources to check out performance. Not as a replacement for a full performance audit.
I am also looking for the pros and cons of such a tool and what results should be kept in perspective regarding the output.
I thank you very much for your involvement.<|eost|><|eoss|><|endoftext|> | 19 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.