subreddit stringclasses 7
values | author stringlengths 3 20 | id stringlengths 5 7 | content stringlengths 67 30.4k | score int64 0 140k |
|---|---|---|---|---|
lolphp | jesseschalken | fbbgpzp | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>"This language can't stop you from doing something stupid."
Well it fucking should. Other languages manage it.<|eor|><|sor|>The point is not whether the language "prevents" you from doing something stupid, but how it handles it once you do.
In this case PHP just inherits C behavior and lets the stack overflow, where normally an interpreted language would track stack size for you and cause a language-level exception/error when some limit is reached so the error can be logged and the program can shutdown gracefully.<|eor|><|eols|><|endoftext|> | 37 |
lolphp | ilogik | fbaujua | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>I'm sure they're only keeping it like this for backwards compatibility.
Somewhere out there there's a site that will break if the segfault doesn't occur.<|eor|><|eols|><|endoftext|> | 28 |
lolphp | AlbertRammstein | fbbycvw | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>In PHP most things are intended behavior. In PHP most things are not bugs, but rather features.<|eor|><|sor|>AFAIK PHP has/had no standard/specification at all, with a mantra "whatever the behavior of the interpreter is is the standard".
Which turns things around - now you are guaranteed there are no bugs in the interpreter, because everything it does is a feature. PHP is the only language to have interpreter with 0 bugs in its history. You do not discover bugs, you discover previously unknown parts of the standard.<|eor|><|eols|><|endoftext|> | 26 |
lolphp | nikic | fbandlm | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>It is a bug, just without an easy fix. General consensus is that stack overflow should be detected based on guard pages, but nobody has implemented this yet.<|eor|><|eols|><|endoftext|> | 20 |
lolphp | jesseschalken | fbbs2v7 | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>"This language can't stop you from doing something stupid."
Well it fucking should. Other languages manage it.<|eor|><|sor|>The point is not whether the language "prevents" you from doing something stupid, but how it handles it once you do.
In this case PHP just inherits C behavior and lets the stack overflow, where normally an interpreted language would track stack size for you and cause a language-level exception/error when some limit is reached so the error can be logged and the program can shutdown gracefully.<|eor|><|sor|>With modern languages the behaviour of C is itself becoming less and less acceptable. Languages can and should prevent you from doing stupid things; the question is now how much stupid you want to get away with and what benefits you get for that sacrifice.
I'm probably preaching to the choir by pointing out that what I want is a useful message when I make a mistake, not a smart-arse response from some tit who thinks PHP has any merit at all.<|eor|><|sor|>I honestly don't understand what you mean by "prevent you from doing stupid things" in this context. Can you name a language that prevents you from doing infinite recursion and running out of stack space (or memory generally)? Maybe some dependently typed languages do?
In any case "stupid things" is an entirely human level concept. The programming language doesn't know what you intended to write because it doesn't know what the specification of your program is. So it's impossible for it to tell you whether you're doing something stupid without you first telling it what "stupid" would mean in your specific case (eg by writing a test or a type).<|eor|><|sor|>Yes, in fact it's a compiler error in Haskell to have an infinite loop and there is a bounty on segfaulting Rust. Obviously there are going to be edge cases but the goal (in my mind as I say these things) is to write a language in which you can specify what you want to be able to do and be told off if you try to do something else. Crashing the process via common mistakes is probably high on the list of things to prevent.<|eor|><|sor|>>it's a compiler error in Haskell to have an infinite loop
No it's not. This code compiles fine and hangs at runtime:
f :: Int -> Int
f = f
main = print (f 1)
[Link](https://repl.it/repls/PunyActualConfiguration)<|eor|><|sor|> They should patch that<|eor|><|sor|>Do you even know what the halting problem is?<|eor|><|eols|><|endoftext|> | 19 |
lolphp | Altreus | fbbk4v2 | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>"This language can't stop you from doing something stupid."
Well it fucking should. Other languages manage it.<|eor|><|sor|>The point is not whether the language "prevents" you from doing something stupid, but how it handles it once you do.
In this case PHP just inherits C behavior and lets the stack overflow, where normally an interpreted language would track stack size for you and cause a language-level exception/error when some limit is reached so the error can be logged and the program can shutdown gracefully.<|eor|><|sor|>With modern languages the behaviour of C is itself becoming less and less acceptable. Languages can and should prevent you from doing stupid things; the question is now how much stupid you want to get away with and what benefits you get for that sacrifice.
I'm probably preaching to the choir by pointing out that what I want is a useful message when I make a mistake, not a smart-arse response from some tit who thinks PHP has any merit at all.<|eor|><|eols|><|endoftext|> | 18 |
lolphp | redwall_hp | fbbs1l2 | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>"This language can't stop you from doing something stupid."
Well it fucking should. Other languages manage it.<|eor|><|sor|>The point is not whether the language "prevents" you from doing something stupid, but how it handles it once you do.
In this case PHP just inherits C behavior and lets the stack overflow, where normally an interpreted language would track stack size for you and cause a language-level exception/error when some limit is reached so the error can be logged and the program can shutdown gracefully.<|eor|><|sor|>PHP inherits a lot of C-isms, which makes zero sense for a higher level interpreted languages that supposedly wants to make things easier and less dangerous.
I've been horrified by this sort of thing in the past, but I don't recall the particularly egregious case.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | jesseschalken | fbbvunl | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>With modern languages the behaviour of C is itself becoming less and less acceptable. Languages can and should prevent you from doing stupid things; the question is now how much stupid you want to get away with and what benefits you get for that sacrifice.
I'm probably preaching to the choir by pointing out that what I want is a useful message when I make a mistake, not a smart-arse response from some tit who thinks PHP has any merit at all.<|eor|><|sor|>I honestly don't understand what you mean by "prevent you from doing stupid things" in this context. Can you name a language that prevents you from doing infinite recursion and running out of stack space (or memory generally)? Maybe some dependently typed languages do?
In any case "stupid things" is an entirely human level concept. The programming language doesn't know what you intended to write because it doesn't know what the specification of your program is. So it's impossible for it to tell you whether you're doing something stupid without you first telling it what "stupid" would mean in your specific case (eg by writing a test or a type).<|eor|><|sor|>Yes, in fact it's a compiler error in Haskell to have an infinite loop and there is a bounty on segfaulting Rust. Obviously there are going to be edge cases but the goal (in my mind as I say these things) is to write a language in which you can specify what you want to be able to do and be told off if you try to do something else. Crashing the process via common mistakes is probably high on the list of things to prevent.<|eor|><|sor|>>it's a compiler error in Haskell to have an infinite loop
No it's not. This code compiles fine and hangs at runtime:
f :: Int -> Int
f = f
main = print (f 1)
[Link](https://repl.it/repls/PunyActualConfiguration)<|eor|><|sor|> They should patch that<|eor|><|sor|>Do you even know what the halting problem is?<|eor|><|sor|>I feel we've gone a long way from "PHP considers recursive data structure to be stupid"
I don't think we're in the same league of problem any more.<|eor|><|sor|>Being able to reject programs which recurse (or loop) infinitely is literally the halting problem.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | jesseschalken | fbbmylf | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>"This language can't stop you from doing something stupid."
Well it fucking should. Other languages manage it.<|eor|><|sor|>The point is not whether the language "prevents" you from doing something stupid, but how it handles it once you do.
In this case PHP just inherits C behavior and lets the stack overflow, where normally an interpreted language would track stack size for you and cause a language-level exception/error when some limit is reached so the error can be logged and the program can shutdown gracefully.<|eor|><|sor|>With modern languages the behaviour of C is itself becoming less and less acceptable. Languages can and should prevent you from doing stupid things; the question is now how much stupid you want to get away with and what benefits you get for that sacrifice.
I'm probably preaching to the choir by pointing out that what I want is a useful message when I make a mistake, not a smart-arse response from some tit who thinks PHP has any merit at all.<|eor|><|sor|>I honestly don't understand what you mean by "prevent you from doing stupid things" in this context. Can you name a language that prevents you from doing infinite recursion and running out of stack space (or memory generally)? Maybe some dependently typed languages do?
In any case "stupid things" is an entirely human level concept. The programming language doesn't know what you intended to write because it doesn't know what the specification of your program is. So it's impossible for it to tell you whether you're doing something stupid without you first telling it what "stupid" would mean in your specific case (eg by writing a test or a type).<|eor|><|sor|>Yes, in fact it's a compiler error in Haskell to have an infinite loop and there is a bounty on segfaulting Rust. Obviously there are going to be edge cases but the goal (in my mind as I say these things) is to write a language in which you can specify what you want to be able to do and be told off if you try to do something else. Crashing the process via common mistakes is probably high on the list of things to prevent.<|eor|><|sor|>>it's a compiler error in Haskell to have an infinite loop
No it's not. This code compiles fine and hangs at runtime:
f :: Int -> Int
f = f
main = print (f 1)
[Link](https://repl.it/repls/PunyActualConfiguration)<|eor|><|eols|><|endoftext|> | 14 |
lolphp | Takeoded | fcy1vql | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>> [2015-03-19 19:52 UTC] omars@php.net
> I'd say the best way to handle this, could be using an ini directive.
And there we have it, the proper fix for any PHP problem.<|eor|><|soopr|>can't wait for the `segfault_on_clone_infinite_recursion=yes` ini option<|eoopr|><|eols|><|endoftext|> | 10 |
lolphp | redwall_hp | fbbs63b | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>In PHP most things are intended behavior. In PHP most things are not bugs, but rather features.<|eor|><|sor|>I prefer the term "accidental feature."<|eor|><|eols|><|endoftext|> | 10 |
lolphp | barubary | fbbydj0 | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>"This language can't stop you from doing something stupid."
Well it fucking should. Other languages manage it.<|eor|><|sor|>The point is not whether the language "prevents" you from doing something stupid, but how it handles it once you do.
In this case PHP just inherits C behavior and lets the stack overflow, where normally an interpreted language would track stack size for you and cause a language-level exception/error when some limit is reached so the error can be logged and the program can shutdown gracefully.<|eor|><|sor|>With modern languages the behaviour of C is itself becoming less and less acceptable. Languages can and should prevent you from doing stupid things; the question is now how much stupid you want to get away with and what benefits you get for that sacrifice.
I'm probably preaching to the choir by pointing out that what I want is a useful message when I make a mistake, not a smart-arse response from some tit who thinks PHP has any merit at all.<|eor|><|sor|>I honestly don't understand what you mean by "prevent you from doing stupid things" in this context. Can you name a language that prevents you from doing infinite recursion and running out of stack space (or memory generally)? Maybe some dependently typed languages do?
In any case "stupid things" is an entirely human level concept. The programming language doesn't know what you intended to write because it doesn't know what the specification of your program is. So it's impossible for it to tell you whether you're doing something stupid without you first telling it what "stupid" would mean in your specific case (eg by writing a test or a type).<|eor|><|sor|>Yes, in fact it's a compiler error in Haskell to have an infinite loop and there is a bounty on segfaulting Rust. Obviously there are going to be edge cases but the goal (in my mind as I say these things) is to write a language in which you can specify what you want to be able to do and be told off if you try to do something else. Crashing the process via common mistakes is probably high on the list of things to prevent.<|eor|><|sor|>If infinite loops are a compiler error, the language is not Turing complete. (Haskell is Turing complete.)<|eor|><|eols|><|endoftext|> | 10 |
lolphp | greyfade | fbbrp1l | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>Some context for this problem:
Linux limits the amount of 'stack' memory that you can use. The reason for this limit is that if you could allocate as much stack memory as you wanted, you would run into memory used for other things. On most Linux systems, this is 8MB, but you can increase the limit. (Running `ulimit -s 10000` will set the limit to 10000KB. Running `ulimit -s unlimited` turns the limit off entirely.)
Whenever you call a function in C, you use a small amount of stack memory. As a rough approximation, it takes `8 * (1 + number of locals)` bytes to represent the function call. This memory is in use until the function exits. If you instead call another function, this will consume more stack memory. If you have a function that calls itself repeatedly, then that will use up all of the stack memory.
For example, this function will crash:
int eat_stack_space(void) { return eat_stack_space(); }
PHP implements a function call in PHP using a function call in C, so it has the same problem.<|eor|><|sor|>> For example, this function will crash:
>
> int eat_stack_space(void) { return eat_stack_space(); }
Well, no, not really. Any sensible compiler will optimize it out, with either a tail-recursive call (which compiles to a jump), or with a do-nothing return. https://godbolt.org/z/uJBFG_<|eor|><|eols|><|endoftext|> | 9 |
lolphp | fell_ratio | fbb1ch3 | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>Some context for this problem:
Linux limits the amount of 'stack' memory that you can use. The reason for this limit is that if you could allocate as much stack memory as you wanted, you would run into memory used for other things. On most Linux systems, this is 8MB, but you can increase the limit. (Running `ulimit -s 10000` will set the limit to 10000KB. Running `ulimit -s unlimited` turns the limit off entirely.)
Whenever you call a function in C, you use a small amount of stack memory. As a rough approximation, it takes `8 * (1 + number of locals)` bytes to represent the function call. This memory is in use until the function exits. If you instead call another function, this will consume more stack memory. If you have a function that calls itself repeatedly, then that will use up all of the stack memory.
For example, this function will crash:
int eat_stack_space(void) { return eat_stack_space(); }
PHP implements a function call in PHP using a function call in C, so it has the same problem.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | fell_ratio | fbbx0k5 | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>Some context for this problem:
Linux limits the amount of 'stack' memory that you can use. The reason for this limit is that if you could allocate as much stack memory as you wanted, you would run into memory used for other things. On most Linux systems, this is 8MB, but you can increase the limit. (Running `ulimit -s 10000` will set the limit to 10000KB. Running `ulimit -s unlimited` turns the limit off entirely.)
Whenever you call a function in C, you use a small amount of stack memory. As a rough approximation, it takes `8 * (1 + number of locals)` bytes to represent the function call. This memory is in use until the function exits. If you instead call another function, this will consume more stack memory. If you have a function that calls itself repeatedly, then that will use up all of the stack memory.
For example, this function will crash:
int eat_stack_space(void) { return eat_stack_space(); }
PHP implements a function call in PHP using a function call in C, so it has the same problem.<|eor|><|sor|>> For example, this function will crash:
>
> int eat_stack_space(void) { return eat_stack_space(); }
Well, no, not really. Any sensible compiler will optimize it out, with either a tail-recursive call (which compiles to a jump), or with a do-nothing return. https://godbolt.org/z/uJBFG_<|eor|><|sor|>Assuming you have optimizations turned on, and that the function can be converted to a tail call, yes. But very small changes will defeat this. For example, if you change the return type to float, and add 0 to the return value, the result is back to a recursive call.
float eat_stack_space(void) {
return eat_stack_space() + 0;
}
https://godbolt.org/z/cd2Jmh<|eor|><|eols|><|endoftext|> | 7 |
lolphp | fell_ratio | fbbyecy | <|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>Some context for this problem:
Linux limits the amount of 'stack' memory that you can use. The reason for this limit is that if you could allocate as much stack memory as you wanted, you would run into memory used for other things. On most Linux systems, this is 8MB, but you can increase the limit. (Running `ulimit -s 10000` will set the limit to 10000KB. Running `ulimit -s unlimited` turns the limit off entirely.)
Whenever you call a function in C, you use a small amount of stack memory. As a rough approximation, it takes `8 * (1 + number of locals)` bytes to represent the function call. This memory is in use until the function exits. If you instead call another function, this will consume more stack memory. If you have a function that calls itself repeatedly, then that will use up all of the stack memory.
For example, this function will crash:
int eat_stack_space(void) { return eat_stack_space(); }
PHP implements a function call in PHP using a function call in C, so it has the same problem.<|eor|><|sor|>Doesn't each process have terabytes worth of addressable virtual memory, and the stack placed at the opposite end of the heap. 8mb seems like an incredibly small amount of the concern is growing the stack into the heap. You are going to run out of even swap space before that happens...<|eor|><|sor|>That's absolutely true.
However, there are some complicating factors. For example, multithreading. If a stack can grow to an unlimited size, how far apart do you need to place two stacks for two different threads? Presumably far enough that the two won't collide even if the first thread uses all of the memory on the system. On the other hand, if you have a fixed limit on stack size, multithreading is no problem: just give each thread 8MB.
Then, there are the other uses of addresses.
* You need to load dynamic libraries into memory, and you don't always know which libraries the process will load at process creation time.
* You need to mmap() files into memory, and those need address space.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | adrenal8 | s24ey | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|eols|><|endoftext|> | 117 |
lolphp | lexyeevee | c4ahzcp | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|sor|>ok overall, this is a very good laundry list.
just a few key defences of some of the features.
> Theres an (array) operator for casting to array. Given that PHP has no other structure type, I dont know why this exists.
This is used to convert between objects defined with `stdClass()` and an associative array... `(object)` can be used to go the other way.
> [] cannot slice; it only retrieves individual elements.
> There are no generators.
These sound like "wah" PHP isn't Python or Ruby. Plenty of modern languages don't have these, these are more "nice to haves". If I have a nice consistent slice function (that can be extended by user defined types) (which PHP doesn't have) and a nice consistent Interator interface that I can hack together with lambda functions.
Oh who am I kidding I abuse the fuck out of the slice operator and generators when I'm coding python.
>Theres redundant syntax for blocks: if (...): ... endif;, etc.
Those are there for embedded templates like:
<?php if($condition): ?>
<h1>condition met!</h1>
<?php endif; ?>
this plus PHP short tags make a decent (if somewhat verbose) built-in template language, this is a questionable thing to have, except PHP (originally) stood for "Hypertext Processor" (except in Portuguese) (I think Maybe that's a backronym)
> PHP errors dont provide stack traces.
and
> PHP errors and PHP exceptions are completely different beasts. They dont seem to interact at all.
This is the default, if you turn on errors as exceptions, you get good stack traces.
see: http://php.net/manual/en/class.errorexception.php, but yeah bad defaults, still bad design, but relatively easy to work around.
> Most error handling is in the form of printing a line to a server log nobody reads and carrying on.
This isn't particularly uncommon in web programming, but it's still a fair, since usually it's because the app designers explicitly caught and logged exceptions, PHP files exceptions and error codes away by default.
> Subclasses cannot override private methods. Subclass overrides of public methods cant even see, let alone call, the superclasss private methods. Problematic for, say, test mocks.
This is the same way in Java & C++, use protected if you want subclasses to see your shit, test mocks can use RelfectionClass & ReflectionMethod to access and call private methods, but it's kind of ugly.
> preg_replace with the /e (eval) flag will do a string replace of the matches into the replacement string, then eval it.
this is part of the PERL regex library and stolen from PERL... ok also a crappy excuse.
> You cant quote keys in variable interpolation, i.e., "$foo['key']" is a syntax error. You can unquote it (which would generate a warning anywhere else!), or use ${...}/{$...}.
As I recall this is because if a constant is undefined it's defined as it's name, so if "key" is an undefined constant, accessing $foo[key] is the same as $foo['key'], which in many ways is just more WTF, than your explanation (this may have changed in recent 5.x stuff). Also doesn't explain the syntax weirdness.
<|eor|><|sor|>hello OP here
> This is used to convert between objects defined with stdClass() and an associative array... (object) can be used to go the other way.
This is insane.
> These sound like "wah" PHP isn't Python or Ruby.
If I could summarize my post that would basically be it, yes.
Perl has had slices since, like, the Stone Age. For a language with a fancy-pants array as its ONLY structure type, lack of slices in any form is kind of wacky.
> Those are there for embedded templates
Oh, I know. They still make for a strange wart, and the readability gain is highly questionable :) And I've never seen them actually used anywhere.
> This is the default, if you turn on errors as exceptions...
By "turn on" do you mean write an error handler that wraps errors in exceptions? That's not any better than using debug_stacktrace, also manually. :( And it still doesn't help with fatals, which don't seem to be catchable by anything.
> This is the same way in Java & C++
Does that make it better or worse?
> this is part of the PERL regex library and stolen from PERL
Actually not quite: if you use s///e in Perl, the replacement string isn't a string at all; it's treated like a legit inline function, gets syntax-checked at compile time, and is executed sanely. PHP looked at this and decided "ok let's just escape quotes and eval it".<|eor|><|eols|><|endoftext|> | 21 |
lolphp | lexyeevee | c4ahzfj | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|sor|>There is a fake mysql escape string! I never knew.<|eor|><|sor|>Yes! It adds SQL injection to the string for you.<|eor|><|eols|><|endoftext|> | 20 |
lolphp | infinull | c4ahkd6 | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|sor|>ok overall, this is a very good laundry list.
just a few key defences of some of the features.
> Theres an (array) operator for casting to array. Given that PHP has no other structure type, I dont know why this exists.
This is used to convert between objects defined with `stdClass()` and an associative array... `(object)` can be used to go the other way.
> [] cannot slice; it only retrieves individual elements.
> There are no generators.
These sound like "wah" PHP isn't Python or Ruby. Plenty of modern languages don't have these, these are more "nice to haves". If I have a nice consistent slice function (that can be extended by user defined types) (which PHP doesn't have) and a nice consistent Interator interface that I can hack together with lambda functions.
Oh who am I kidding I abuse the fuck out of the slice operator and generators when I'm coding python.
>Theres redundant syntax for blocks: if (...): ... endif;, etc.
Those are there for embedded templates like:
<?php if($condition): ?>
<h1>condition met!</h1>
<?php endif; ?>
this plus PHP short tags make a decent (if somewhat verbose) built-in template language, this is a questionable thing to have, except PHP (originally) stood for "Hypertext Processor" (except in Portuguese) (I think Maybe that's a backronym)
> PHP errors dont provide stack traces.
and
> PHP errors and PHP exceptions are completely different beasts. They dont seem to interact at all.
This is the default, if you turn on errors as exceptions, you get good stack traces.
see: http://php.net/manual/en/class.errorexception.php, but yeah bad defaults, still bad design, but relatively easy to work around.
> Most error handling is in the form of printing a line to a server log nobody reads and carrying on.
This isn't particularly uncommon in web programming, but it's still a fair, since usually it's because the app designers explicitly caught and logged exceptions, PHP files exceptions and error codes away by default.
> Subclasses cannot override private methods. Subclass overrides of public methods cant even see, let alone call, the superclasss private methods. Problematic for, say, test mocks.
This is the same way in Java & C++, use protected if you want subclasses to see your shit, test mocks can use RelfectionClass & ReflectionMethod to access and call private methods, but it's kind of ugly.
> preg_replace with the /e (eval) flag will do a string replace of the matches into the replacement string, then eval it.
this is part of the PERL regex library and stolen from PERL... ok also a crappy excuse.
> You cant quote keys in variable interpolation, i.e., "$foo['key']" is a syntax error. You can unquote it (which would generate a warning anywhere else!), or use ${...}/{$...}.
As I recall this is because if a constant is undefined it's defined as it's name, so if "key" is an undefined constant, accessing $foo[key] is the same as $foo['key'], which in many ways is just more WTF, than your explanation (this may have changed in recent 5.x stuff). Also doesn't explain the syntax weirdness.
<|eor|><|eols|><|endoftext|> | 17 |
lolphp | dagbrown | c4aiqnq | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|sor|>This article certainly lives up to its name! The further you get into it, the more detailed the complaints yet, and yet the amount of wrongness stays the same.
A TL;DR version of this article would be "PHP's vast huge errors serve only to distract you from its multitude of smaller errors, each of which in turn are built on top of another, smaller but by no means less wrong layer of errors, and so on ad infinitum." But then again, that's the title.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | farsightxr20 | c4ai2qs | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|sor|>"Design"
you must be new to PHP<|eor|><|sor|>"DESIGN"?!?? SORRY, I USE AGILE DEVELOPMENT METHODOLOGIES.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | dagbrown | c4aixh9 | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|sor|>"Design"
you must be new to PHP<|eor|><|sor|>PHP wasn't designed--it grew.
Actually, that's being way too kind to it. It hasn't so much grown as *accreted*. Look at the million regex-match functions it has. Or the bizarre return value (to say nothing of the parameters) from its strange "I HAVE NO IDEA WHAT I'M DOING" version of `system()`.<|eor|><|sor|>I call it *The Katamary Damarcy of Programming*.<|eor|><|sor|>Only it's one of those katamaris which is really unbalanced--instead of getting a whole bunch of ball-shaped things, you got a collection of rakes and brooms and things with really awkward shapes like that, and whenever you try to roll it anywhere, it fights back against you. And yet it's not quite big enough to get over the barriers.
I think I took that metaphor just a little too far.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | dipswitch | c4aj15o | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|sor|>re closures and use :
$a = array();
$f = function() use($a) { $a[] = 1; };
$f();
print(count($a)); # 0
$f = function() use(&$a) { $a[] = 1; };
$f();
print(count($a)); # 1
<|eor|><|sor|>so... the closed-over vars use the same pass semantics as regular function calls? what<|eor|><|sor|>yes, what? indeed. In the places where I have used them I stare at the code thinking : "have I actually achieved anything doing it like that except baffle the next poor sod who has to read it".<|eor|><|sor|>That's nothing, consider this (contrived example but you get the idea)
$fuckphp = $this;
$x = array_map(function($arg) use($fuckphp) {
return $fuckphp->foo($arg); // can only call public methods here
}, $arr);
Using $this directly would result in a fatal error "Cannot use $this as lexical variable.". This was fixed in 5.4 so in 2 years we'll finally be able to use closures in OO code.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | lexyeevee | c4ahzjj | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|sor|>re closures and use :
$a = array();
$f = function() use($a) { $a[] = 1; };
$f();
print(count($a)); # 0
$f = function() use(&$a) { $a[] = 1; };
$f();
print(count($a)); # 1
<|eor|><|sor|>so... the closed-over vars use the same pass semantics as regular function calls? what<|eor|><|eols|><|endoftext|> | 6 |
lolphp | dagbrown | c4aipuw | <|sols|><|sot|>PHP: a fractal of bad design<|eot|><|sol|>http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/<|eol|><|sor|>"Design"
you must be new to PHP<|eor|><|sor|>PHP wasn't designed--it grew.
Actually, that's being way too kind to it. It hasn't so much grown as *accreted*. Look at the million regex-match functions it has. Or the bizarre return value (to say nothing of the parameters) from its strange "I HAVE NO IDEA WHAT I'M DOING" version of `system()`.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | muglug | 7hrc21 | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|eols|><|endoftext|> | 114 |
lolphp | h0rst_ | dqtdhjx | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>https://3v4l.org/SkrAi
Auto type conversion on steroids (or crack)<|eor|><|eols|><|endoftext|> | 74 |
lolphp | andsens | dqt7ios | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>ok, so my theory is that the `char*` gets cast to `long*`, dereferenced, incremented and stored back into memory as a long. then when we echo the string it is treated as a `char*` again.
But that is only a guess and by the time I finished writing that I realized that unless there is some endianess stuff going on when it gets cast we should end up with `68 65 6c 6c 6f 00 00 00`, or 7,522,537,965,566,820,352 whichever you prefer. So if we increment the long we get `68 65 6c 6c 6f 00 00 01` and the string remains the same. so probably not the answer.<|eor|><|sor|>It's intentional and taken from Perl actually:
> PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in PHP and Perl $a = 'Z'; $a++; turns $a into 'AA', while in C a = 'Z'; a++; turns a into '[' (ASCII value of 'Z' is 90, ASCII value of '[' is 91). Note that character variables can be incremented but not decremented and even so only plain ASCII alphabets and digits (a-z, A-Z and 0-9) are supported. Incrementing/decrementing other character variables has no effect, the original string is unchanged.
[source](https://secure.php.net/manual/en/language.operators.increment.php)<|eor|><|eols|><|endoftext|> | 20 |
lolphp | SirClueless | dqtezui | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>https://3v4l.org/SkrAi
Auto type conversion on steroids (or crack)<|eor|><|sor|>( <|eor|><|eols|><|endoftext|> | 18 |
lolphp | dagbrown | dqu0kwc | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>https://3v4l.org/SkrAi
Auto type conversion on steroids (or crack)<|eor|><|sor|>it thinks the e means its scientific notation<|eor|><|sor|>But also that d means hex
Edit: Looks like they have base 26 actually... Because that's so common<|eor|><|sor|>Base 36 apparently, which people ask for all the time I'm sure.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | HotRodLincoln | dqteu3a | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>incrementing strings treats them like a base 26 number. so 'a' becomes 'b'. 'z' becomes 'aa'.<|eor|><|sor|>But only if it's a single letter. 'quiz' becomes '[quja](https://3v4l.org/1ZhUG)', not 'quiaa'<|eor|><|sor|>That would be like 129 going to 130. 'z' loops to 'a' and the 'i' increments to 'j'. <|eor|><|sor|>I read the explanation and still expected 'quj0'.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | barubary | dqtyu9b | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>ok, so my theory is that the `char*` gets cast to `long*`, dereferenced, incremented and stored back into memory as a long. then when we echo the string it is treated as a `char*` again.
But that is only a guess and by the time I finished writing that I realized that unless there is some endianess stuff going on when it gets cast we should end up with `68 65 6c 6c 6f 00 00 00`, or 7,522,537,965,566,820,352 whichever you prefer. So if we increment the long we get `68 65 6c 6c 6f 00 00 01` and the string remains the same. so probably not the answer.<|eor|><|sor|>It's intentional and taken from Perl actually:
> PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in PHP and Perl $a = 'Z'; $a++; turns $a into 'AA', while in C a = 'Z'; a++; turns a into '[' (ASCII value of 'Z' is 90, ASCII value of '[' is 91). Note that character variables can be incremented but not decremented and even so only plain ASCII alphabets and digits (a-z, A-Z and 0-9) are supported. Incrementing/decrementing other character variables has no effect, the original string is unchanged.
[source](https://secure.php.net/manual/en/language.operators.increment.php)<|eor|><|sor|>But why, though?<|eor|><|sor|>In Perl at least you can use it to create ranges:
for my $c ('A' .. 'Z') # loop through all letters
or
for my $cc ('AA' .. 'ZZ') # loop through all 2-letter combinations
Perl is more conservative about which strings get this special treatment in `++`, though. Trying to increment e.g. `1d9` results in `Argument "1d9" isn't numeric in preincrement (++)`.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | chewitt | dqtbkk8 | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>incrementing strings treats them like a base 26 number. so 'a' becomes 'b'. 'z' becomes 'aa'.<|eor|><|sor|>But only if it's a single letter. 'quiz' becomes '[quja](https://3v4l.org/1ZhUG)', not 'quiaa'<|eor|><|eols|><|endoftext|> | 9 |
lolphp | coredumperror | dqt95fp | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>ok, so my theory is that the `char*` gets cast to `long*`, dereferenced, incremented and stored back into memory as a long. then when we echo the string it is treated as a `char*` again.
But that is only a guess and by the time I finished writing that I realized that unless there is some endianess stuff going on when it gets cast we should end up with `68 65 6c 6c 6f 00 00 00`, or 7,522,537,965,566,820,352 whichever you prefer. So if we increment the long we get `68 65 6c 6c 6f 00 00 01` and the string remains the same. so probably not the answer.<|eor|><|sor|>It's intentional and taken from Perl actually:
> PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in PHP and Perl $a = 'Z'; $a++; turns $a into 'AA', while in C a = 'Z'; a++; turns a into '[' (ASCII value of 'Z' is 90, ASCII value of '[' is 91). Note that character variables can be incremented but not decremented and even so only plain ASCII alphabets and digits (a-z, A-Z and 0-9) are supported. Incrementing/decrementing other character variables has no effect, the original string is unchanged.
[source](https://secure.php.net/manual/en/language.operators.increment.php)<|eor|><|sor|>But why, though?<|eor|><|eols|><|endoftext|> | 8 |
lolphp | SirClueless | dqtes3q | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>ok, so my theory is that the `char*` gets cast to `long*`, dereferenced, incremented and stored back into memory as a long. then when we echo the string it is treated as a `char*` again.
But that is only a guess and by the time I finished writing that I realized that unless there is some endianess stuff going on when it gets cast we should end up with `68 65 6c 6c 6f 00 00 00`, or 7,522,537,965,566,820,352 whichever you prefer. So if we increment the long we get `68 65 6c 6c 6f 00 00 01` and the string remains the same. so probably not the answer.<|eor|><|sor|>It's intentional and taken from Perl actually:
> PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in PHP and Perl $a = 'Z'; $a++; turns $a into 'AA', while in C a = 'Z'; a++; turns a into '[' (ASCII value of 'Z' is 90, ASCII value of '[' is 91). Note that character variables can be incremented but not decremented and even so only plain ASCII alphabets and digits (a-z, A-Z and 0-9) are supported. Incrementing/decrementing other character variables has no effect, the original string is unchanged.
[source](https://secure.php.net/manual/en/language.operators.increment.php)<|eor|><|sor|>But why, though?<|eor|><|sor|>Probably so that you can loop through strings, Excel column-heading style.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | jpresutti | dsf12fx | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>https://3v4l.org/SkrAi
Auto type conversion on steroids (or crack)<|eor|><|sor|>it thinks the e means its scientific notation<|eor|><|sor|>But also that d means hex
Edit: Looks like they have base 26 actually... Because that's so common<|eor|><|sor|>Base 36 apparently, which people ask for all the time I'm sure.<|eor|><|sor|>Feature. It actually is not "base 26" or "base anything". It keeps capital letters capital and lowercase lowercase. It keeps numbers numbers
hELLo would become hELLp
heLLz would become heLMa
heZZz would become hfAAa
he9zz becomes hf0aa
Is it crazy? Yes. Is it cool? Yes, especially if you enjoy trivia. Have I *ever* in ELEVEN years of PHP found a use for it? No.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | jghgjb790 | dqu98kq | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>incrementing strings treats them like a base 26 number. so 'a' becomes 'b'. 'z' becomes 'aa'.<|eor|><|sor|>But only if it's a single letter. 'quiz' becomes '[quja](https://3v4l.org/1ZhUG)', not 'quiaa'<|eor|><|sor|>That would be like 129 going to 130. 'z' loops to 'a' and the 'i' increments to 'j'. <|eor|><|sor|>I read the explanation and still expected 'quj0'.<|eor|><|sor|>Base 26 plus PHP<|eor|><|eols|><|endoftext|> | 8 |
lolphp | doubtfulwager | dqu9xpe | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|> <?php
$init_state = ['',' ','a','-a',0,-0,0.00,-0.00,null,true,false];
foreach ($init_state as $val) {
$ip = $val;
$in = $val;
$pi = $val;
$ni = $val;
--$ip;
$in--;
++$pi;
--$ni;
echo str_pad('['.gettype($val).']',9);
echo str_pad($val,6);
echo ' [i++] ' . @str_pad($ip, 6);
echo ' [i--] ' . @str_pad($in, 6);
echo ' [++i] ' . @str_pad($pi, 6);
echo ' [--i] ' . @str_pad($ni, 6);
echo "\n";
}
[string] [i++] -1 [i--] -1 [++i] 1 [--i] -1
[string] [i++] [i--] [++i] [--i]
[string] a [i++] a [i--] a [++i] b [--i] a
[string] -a [i++] -a [i--] -a [++i] -b [--i] -a
[integer]0 [i++] -1 [i--] -1 [++i] 1 [--i] -1
[integer]0 [i++] -1 [i--] -1 [++i] 1 [--i] -1
[double] 0 [i++] -1 [i--] -1 [++i] 1 [--i] -1
[double] -0 [i++] -1 [i--] -1 [++i] 1 [--i] -1
[NULL] [i++] [i--] [++i] 1 [--i]
[boolean]1 [i++] 1 [i--] 1 [++i] 1 [--i] 1
[boolean] [i++] [i--] [++i] [--i]
<|eor|><|eols|><|endoftext|> | 7 |
lolphp | h0rst_ | drdc7vs | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>https://3v4l.org/SkrAi
Auto type conversion on steroids (or crack)<|eor|><|sor|>How does 1d9 + 1 = 1e0? What is happening here?<|eor|><|sor|>The same way as 129 + 1 = 130: you add 1 to the last digits, it becomes 10 an the 1 is carried to the number before the 9. In the same way, incrementing "1z" becomes "2a".<|eor|><|eols|><|endoftext|> | 7 |
lolphp | h0rst_ | drdcgz0 | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>https://3v4l.org/SkrAi
Auto type conversion on steroids (or crack)<|eor|><|sor|>Hah, trying to reproduce it locally and got another crazy error http://0x0.st/sXtr.png
<|eor|><|sor|>Ah, the infamous [T_PAAMAYIM_NEKUDOTAYIM](https://philsturgeon.uk/php/2013/09/09/t-paamayim-nekudotayim-v-sanity/)
But besides that, I agree with PHP not being able to parse this code. `++` is a shorthand for `X = X + 1`, which makes no sense using on a constant (`"1d9" = "1d9" + 1`), or nested (`X = (X = X + 1) + 1`)<|eor|><|eols|><|endoftext|> | 7 |
lolphp | dagbrown | dqu5w7t | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>ok, so my theory is that the `char*` gets cast to `long*`, dereferenced, incremented and stored back into memory as a long. then when we echo the string it is treated as a `char*` again.
But that is only a guess and by the time I finished writing that I realized that unless there is some endianess stuff going on when it gets cast we should end up with `68 65 6c 6c 6f 00 00 00`, or 7,522,537,965,566,820,352 whichever you prefer. So if we increment the long we get `68 65 6c 6c 6f 00 00 01` and the string remains the same. so probably not the answer.<|eor|><|sor|>It's intentional and taken from Perl actually:
> PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in PHP and Perl $a = 'Z'; $a++; turns $a into 'AA', while in C a = 'Z'; a++; turns a into '[' (ASCII value of 'Z' is 90, ASCII value of '[' is 91). Note that character variables can be incremented but not decremented and even so only plain ASCII alphabets and digits (a-z, A-Z and 0-9) are supported. Incrementing/decrementing other character variables has no effect, the original string is unchanged.
[source](https://secure.php.net/manual/en/language.operators.increment.php)<|eor|><|sor|>But why, though?<|eor|><|sor|>In Perl at least you can use it to create ranges:
for my $c ('A' .. 'Z') # loop through all letters
or
for my $cc ('AA' .. 'ZZ') # loop through all 2-letter combinations
Perl is more conservative about which strings get this special treatment in `++`, though. Trying to increment e.g. `1d9` results in `Argument "1d9" isn't numeric in preincrement (++)`.<|eor|><|sor|> $ perl -e '$a = "1d9"; $a++; print "$a\n";'
2
It just gets there quicker than PHP. What's actually going on here is that it parses the string as a number until it finds something which is clearly not numeric, and uses that as the value for the increment.
Turning on warnings does result in the error message, but it also carries on and tries it anyway.
Python and Ruby both do the right thing and error out with complaints about how adding integers to strings doesn't make any sense (Ruby provides a `String#next` if you really want the behaviour that PHP makes up, only without relying on the interpreter to guess what you wanted).<|eor|><|eols|><|endoftext|> | 7 |
lolphp | randomuser8765 | drivx17 | <|sols|><|sot|>$a = "hello"; $a++; echo $a;<|eot|><|sol|>https://3v4l.org/p5Apm<|eol|><|sor|>https://3v4l.org/SkrAi
Auto type conversion on steroids (or crack)<|eor|><|sor|>How does 1d9 + 1 = 1e0? What is happening here?<|eor|><|sor|>The same way as 129 + 1 = 130: you add 1 to the last digits, it becomes 10 an the 1 is carried to the number before the 9. In the same way, incrementing "1z" becomes "2a".<|eor|><|sor|>That has to be some of the blindest/dumbest code I have ever seen. A number where the ones digit is numeric and the tens digit is a letter is apparently a valid number?<|eor|><|sor|>Both 1d9 and 1e0 are totally valid hexadecimal numbers for instance. <|eor|><|sor|>But in hex, 1d9 + 1 = 1da, so clearly that's not what's happening.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | SockPants | 31s7ya | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|eols|><|endoftext|> | 118 |
lolphp | senatorpjt | cq4tecl | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>How is competency controlled for? Once devs become competent, they stop using PHP.<|eor|><|eols|><|endoftext|> | 42 |
lolphp | svtguy88 | cq4kz3w | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>So...I know the coasts and other "hot tech areas" get a substantial pay premium, but am I the only one that thinks these all seem a bit on the high side?
Either that, or I need a raise.
*source: C#/JavaScript dev being paid well under $95k*<|eor|><|eols|><|endoftext|> | 26 |
lolphp | TheBuzzSaw | cq4nrs1 | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>So...I know the coasts and other "hot tech areas" get a substantial pay premium, but am I the only one that thinks these all seem a bit on the high side?
Either that, or I need a raise.
*source: C#/JavaScript dev being paid well under $95k*<|eor|><|sor|>They are indeed high. Areas with high cost-of-living mixed with the "average" engineer being in the "middle" of their career (several raises) swings them upward.
You can buy a great house in Texas for $120k. You can buy the same house in California for like $1.2 million. XD<|eor|><|eols|><|endoftext|> | 25 |
lolphp | tobiasvl | cq55gxy | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>As a European, I'm interested in those other two tabs as well. Why would you not include then, is this a US sub? <|eor|><|eols|><|endoftext|> | 13 |
lolphp | polish_niceguy | cq5tzlm | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>How is competency controlled for? Once devs become competent, they stop using PHP.<|eor|><|sor|>Not necessarily. It's popular, easy to host and you can produce decent code if you are competent. You don't have to love it, just make money out of it.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | cliath | cq4w8wu | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>So...I know the coasts and other "hot tech areas" get a substantial pay premium, but am I the only one that thinks these all seem a bit on the high side?
Either that, or I need a raise.
*source: C#/JavaScript dev being paid well under $95k*<|eor|><|sor|>They are indeed high. Areas with high cost-of-living mixed with the "average" engineer being in the "middle" of their career (several raises) swings them upward.
You can buy a great house in Texas for $120k. You can buy the same house in California for like $1.2 million. XD<|eor|><|sor|>Calling BS on a great house in Texas for $120k, at least in areas where developers are needed. I've been in Texas for 6 years.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | allthediamonds | cq4nulu | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>Well, it's not surprising they get paid like juniors considering they're overwhelmingly juniors.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | OneWingedShark | cq4ja56 | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>Interesting.
Supply and Demand?<|eor|><|eols|><|endoftext|> | 9 |
lolphp | OneWingedShark | cq4n3w1 | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>Interesting.
Supply and Demand?<|eor|><|sor|>[deleted]<|eor|><|sor|>I just wish the demand weren't so high. :/<|eor|><|eols|><|endoftext|> | 9 |
lolphp | cfreak2399 | cq5b98u | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>So...I know the coasts and other "hot tech areas" get a substantial pay premium, but am I the only one that thinks these all seem a bit on the high side?
Either that, or I need a raise.
*source: C#/JavaScript dev being paid well under $95k*<|eor|><|sor|>They are indeed high. Areas with high cost-of-living mixed with the "average" engineer being in the "middle" of their career (several raises) swings them upward.
You can buy a great house in Texas for $120k. You can buy the same house in California for like $1.2 million. XD<|eor|><|sor|>Calling BS on a great house in Texas for $120k, at least in areas where developers are needed. I've been in Texas for 6 years.<|eor|><|sor|>You could get a house for $120k. It would be small and maybe not the richest neighborhood but still safe and decent. $150k is probably a little easier. Lots of new neighborhoods with their smaller houses in that range.
The point still stands though. a 3 bed - 2 bath home is going to be less than 1/5 the cost of what it is in CA or NYC.
Source: live in DFW<|eor|><|eols|><|endoftext|> | 9 |
lolphp | jb2386 | cq4rsi0 | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>Well, that's USA. Here in Australia it's different at least. I make a mint with PHP.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | SockPants | cq55l3w | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>As a European, I'm interested in those other two tabs as well. Why would you not include then, is this a US sub? <|eor|><|soopr|>The trend was most clear in this category. The entire survey is [here](http://stackoverflow.com/research/developer-survey-2015?utm_medium=social&utm_campaign=stack-overflow-survey&utm_source=reddit.com), lots of nice results! Interestingly PHP is not in the Most Dreaded category, nor in the Most Loved category. It's sort of just neutral or don't care.<|eoopr|><|eols|><|endoftext|> | 7 |
lolphp | eof | cq4mmt7 | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>So...I know the coasts and other "hot tech areas" get a substantial pay premium, but am I the only one that thinks these all seem a bit on the high side?
Either that, or I need a raise.
*source: C#/JavaScript dev being paid well under $95k*<|eor|><|sor|>Seems right to me since west coast salaries are significantly higher than what's listed there, and the outliers are much much farther from the mean on the high end than the low end<|eor|><|eols|><|endoftext|> | 7 |
lolphp | bios_hazard | cq57trs | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>Interesting.
Supply and Demand?<|eor|><|sor|>[deleted]<|eor|><|sor|>I just wish the demand weren't so high. :/<|eor|><|sor|>Indeed. Know it down to the interpreter and you'll probably be better than 90% of other PHP programmers. I'm working on that myself.<|eor|><|sor|>> Know it down to the interpreter
What do you mean by this? Like... go through the PHP source code?
<|eor|><|eols|><|endoftext|> | 7 |
lolphp | __constructor | cqubiht | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>This isn't "regardless of competency" it's "without taking competency into account".
PHP's userbase is polluted with low-effort, low-pay positions. At the senior levels, PHP developers make par with other languages.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | OneWingedShark | cq5ek13 | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>Interesting.
Supply and Demand?<|eor|><|sor|>[deleted]<|eor|><|sor|>I just wish the demand weren't so high. :/<|eor|><|sor|>Indeed. Know it down to the interpreter and you'll probably be better than 90% of other PHP programmers. I'm working on that myself.<|eor|><|sor|>You know, I'd rather put time and effort into learning a tool (compilers and interpreters are tools) which *helps* me rather than not. -- Since I do a good chunk of maintenance and Ada was designed with maintainability as one of its design-goals (the other being correctness)^1 I find myself really liking it.
^1 --"'Incorrect' is simply not allowed!"<|eor|><|eols|><|endoftext|> | 6 |
lolphp | tinkermake | cq4rq2v | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>So...I know the coasts and other "hot tech areas" get a substantial pay premium, but am I the only one that thinks these all seem a bit on the high side?
Either that, or I need a raise.
*source: C#/JavaScript dev being paid well under $95k*<|eor|><|sor|>Ny area I'm seeing js/c# listing with 1-3 yrs experience at around 100-120<|eor|><|eols|><|endoftext|> | 5 |
lolphp | ZorbaTHut | cq500hl | <|sols|><|sot|>PHP devs earn less than any other devs regardless of competency.<|eot|><|sol|>http://i.imgur.com/qjQxzBz.png<|eol|><|sor|>So...I know the coasts and other "hot tech areas" get a substantial pay premium, but am I the only one that thinks these all seem a bit on the high side?
Either that, or I need a raise.
*source: C#/JavaScript dev being paid well under $95k*<|eor|><|sor|>It really does depend on where you live. I code in C++ in the games industry, which is well known for having low pay . . . but I'm in the SF Bay Area, and as a result all of those salaries look low to me. The Objective-C salary is a just-barely-senior-engineer gamedev salary around here. The rest are too low.
Meanwhile, I pay $2/sqft/mo for rent, and if I had a cool million bucks, I'd have trouble buying a dilapidated shack to live in. Win some, lose some.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Takeoded | pulak7 | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|eols|><|endoftext|> | 118 |
lolphp | current_thread | he426n3 | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|eols|><|endoftext|> | 36 |
lolphp | colshrapnel | he4449g | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|sor|>Because false is a special return value in PHP for many built-in functions and legacy code. A function either returns an expected value or false on error.<|eor|><|eols|><|endoftext|> | 28 |
lolphp | regretdeletingthat | he4fmdl | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>This makes perfect sense in the context of what is already in the PHP stdlib. Many many built-in functions return some value or false on error.
Is it ideal? No. Is it good to be able to precisely type hint these things while theyre still around? Absolutely.<|eor|><|eols|><|endoftext|> | 23 |
lolphp | stfcfanhazz | he4ox1d | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>Although I understand why, I think this post is indeed worthy of this sub.<|eor|><|eols|><|endoftext|> | 22 |
lolphp | colshrapnel | he476vx | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|sor|>Because false is a special return value in PHP for many built-in functions and legacy code. A function either returns an expected value or false on error.<|eor|><|sor|>Couldn't they've just used `Int|Bool` then?<|eor|><|sor|>Obviously no. Because such a function is either returns int or false, not int, false or true.<|eor|><|eols|><|endoftext|> | 22 |
lolphp | Takeoded | he4rfm2 | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|sor|>Because false is a special return value in PHP for many built-in functions and legacy code. A function either returns an expected value or false on error.<|eor|><|sor|>Couldn't they've just used `Int|Bool` then?<|eor|><|sor|>Obviously no. Because such a function is either returns int or false, not int, false or true.<|eor|><|sor|>wat<|eor|><|sor|>method never returns true.
bool is too broad<|eor|><|soopr|>by the same logic, `int` is too broad of a return type for strpos() because strpos() never returns negative numbers, but int can contain negative numbers? time for unsignedInt/positiveInt<|eoopr|><|eols|><|endoftext|> | 14 |
lolphp | bkdotcom | he4ucmk | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|sor|>Because false is a special return value in PHP for many built-in functions and legacy code. A function either returns an expected value or false on error.<|eor|><|sor|>Couldn't they've just used `Int|Bool` then?<|eor|><|sor|>Obviously no. Because such a function is either returns int or false, not int, false or true.<|eor|><|sor|>wat<|eor|><|sor|>method never returns true.
bool is too broad<|eor|><|soopr|>by the same logic, `int` is too broad of a return type for strpos() because strpos() never returns negative numbers, but int can contain negative numbers? time for unsignedInt/positiveInt<|eoopr|><|sor|>I'll give you that<|eor|><|eols|><|endoftext|> | 12 |
lolphp | duskwuff | he4iv0r | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|sor|>Because false is a special return value in PHP for many built-in functions and legacy code. A function either returns an expected value or false on error.<|eor|><|sor|>Couldn't they've just used `Int|Bool` then?<|eor|><|sor|>Obviously no. Because such a function is either returns int or false, not int, false or true.<|eor|><|sor|>wat<|eor|><|sor|>These functions return false under failure conditions. If they were designed today, they'd probably return null or throw an exception instead, but that's water under the bridge.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | current_thread | he44asq | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|sor|>Because false is a special return value in PHP for many built-in functions and legacy code. A function either returns an expected value or false on error.<|eor|><|sor|>Couldn't they've just used `Int|Bool` then?<|eor|><|eols|><|endoftext|> | 10 |
lolphp | nikic | hezhh56 | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|sor|>Because false is a special return value in PHP for many built-in functions and legacy code. A function either returns an expected value or false on error.<|eor|><|sor|>Couldn't they've just used `Int|Bool` then?<|eor|><|sor|>Obviously no. Because such a function is either returns int or false, not int, false or true.<|eor|><|sor|>wat<|eor|><|sor|>method never returns true.
bool is too broad<|eor|><|soopr|>by the same logic, `int` is too broad of a return type for strpos() because strpos() never returns negative numbers, but int can contain negative numbers? time for unsignedInt/positiveInt<|eoopr|><|sor|>There's an important practical difference here. Having `int|false` rather than `int|bool` as the return type allows static analyzers to reason that in
if (false !== $pos = strpos($str1, $str2)) {
return null;
}
// Do something with $pos
the variable `$pos` is always an integer after the if. With `int|bool` it would be an `int|true` instead, which would be borderline useless. This holds for other functions returning false as an error/not-found indicator as well.
Knowing that the return value can't be negative is a nice gimmick, but it's not particularly important for type inference.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | regretdeletingthat | he5gmkd | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>This makes perfect sense in the context of what is already in the PHP stdlib. Many many built-in functions return some value or false on error.
Is it ideal? No. Is it good to be able to precisely type hint these things while theyre still around? Absolutely.<|eor|><|sor|>The problem is consistency. If I can use literal 'false' as a return type I should be able to use literal 'true'... I would even argue that you should be able to use any literal value. Type should not be constrained to class, this way too rudimentary.
Inconsistencies like that are annoying in a codebase, but in a language they are poison. You are loging debt with an half baked feature. It's better to not have it at all than having a badly implemented feature with unjustified limitations.<|eor|><|sor|>Its not really half baked thoughit was a deliberate decision. I agree that literal types would be a great feature; TypeScript has them and theyre very useful (although mostly because, not unlike PHP, there is a lot of JavaScript already out there that works on magic strings).
But the reasoning behind `val|false` was a concession towards the sheer volume of existing functions with that signature. Its an easy win that wouldnt require anywhere near the work that full literal type support would.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | regretdeletingthat | he5fygc | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>This makes perfect sense in the context of what is already in the PHP stdlib. Many many built-in functions return some value or false on error.
Is it ideal? No. Is it good to be able to precisely type hint these things while theyre still around? Absolutely.<|eor|><|sor|>For historical reasons. The classic PHP excuse for shit design.
https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eor|><|sor|>Yeah it is shit design. But theres billions upon billions of lines of PHP already out there, and the core teams consideration of back compat makes keeping those codebases up to date very simple in most cases. Theres already enough pwnable Wordpress installs out there, huge breaking changes every major release helps no-one.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | kyou20 | he57z0b | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|sor|>Because false is a special return value in PHP for many built-in functions and legacy code. A function either returns an expected value or false on error.<|eor|><|sor|>Couldn't they've just used `Int|Bool` then?<|eor|><|sor|>Obviously no. Because such a function is either returns int or false, not int, false or true.<|eor|><|sor|>wat<|eor|><|sor|>method never returns true.
bool is too broad<|eor|><|soopr|>by the same logic, `int` is too broad of a return type for strpos() because strpos() never returns negative numbers, but int can contain negative numbers? time for unsignedInt/positiveInt<|eoopr|><|sor|>Yes?<|eor|><|eols|><|endoftext|> | 8 |
lolphp | mr_ywg | he566kw | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>This makes perfect sense in the context of what is already in the PHP stdlib. Many many built-in functions return some value or false on error.
Is it ideal? No. Is it good to be able to precisely type hint these things while theyre still around? Absolutely.<|eor|><|sor|>The problem is consistency. If I can use literal 'false' as a return type I should be able to use literal 'true'... I would even argue that you should be able to use any literal value. Type should not be constrained to class, this way too rudimentary.
Inconsistencies like that are annoying in a codebase, but in a language they are poison. You are loging debt with an half baked feature. It's better to not have it at all than having a badly implemented feature with unjustified limitations.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | bkdotcom | he4g02k | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>WHY?! That's finally some good /r/lolphp material...<|eor|><|sor|>Because false is a special return value in PHP for many built-in functions and legacy code. A function either returns an expected value or false on error.<|eor|><|sor|>Couldn't they've just used `Int|Bool` then?<|eor|><|sor|>Obviously no. Because such a function is either returns int or false, not int, false or true.<|eor|><|sor|>wat<|eor|><|sor|>method never returns true.
bool is too broad<|eor|><|eols|><|endoftext|> | 6 |
lolphp | kyou20 | he58qmf | <|sols|><|sot|>as of php8, int|false is a valid return type, but int|true is illegal<|eot|><|sol|>https://3v4l.org/uD2LA<|eol|><|sor|>This makes perfect sense in the context of what is already in the PHP stdlib. Many many built-in functions return some value or false on error.
Is it ideal? No. Is it good to be able to precisely type hint these things while theyre still around? Absolutely.<|eor|><|soopr|>>Many many built-in functions return some value or false on error.
ideally someone should go back in time to 1995 and convince Rasmus that those functions should return val|null, not val|false, but to change those functions *today* to return null instead of false would break so incredibly much old code in the style of `if(false!==stripos(...)){...}```, so it's not really possible today, not even for a major version release, i think.. maybe Hack could do it though<|eoopr|><|sor|>So? Major number upgrades are expected to come with breaking changes. PHP is still shit nowadays because if its for historical reasons bullshit.
https://reddit.com/r/lolphp/comments/62ziz4/sitephpnet_intexthistorical_reasons/
https://www.google.com/search?q=site%3Aphp.net+intext%3Ahistorical+reasons<|eor|><|eols|><|endoftext|> | 5 |
lolphp | ManchegoObfuscator | 1l8fru | <|sols|><|sot|>[from r/PHP] Creating a user from the web problem.<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/1l7baq/creating_a_user_from_the_web_problem/<|eol|><|eols|><|endoftext|> | 116 |
lolphp | Sarcastinator | cbwtlmc | <|sols|><|sot|>[from r/PHP] Creating a user from the web problem.<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/1l7baq/creating_a_user_from_the_web_problem/<|eol|><|sor|>Why. Oh god why.
I need a drink.<|eor|><|sor|>I mean..I know it's not making fun of PHP specifically and you can easily do something that horrific if other languages but....I think this still deserves to be up here.
I think I need a drink too...and also someone needs to stab me in the eye with an ice pick. <|eor|><|sor|>It's much harder in Python (for example) though, you have to pass in each argument as an iterable (unless you do shell=True... which you shouldn't usually.)
from subprocess import check_call
check_call(('/usr/bin/sudo', 'useradd', '-p', encpass, '-g', 'groupname', '-s', '/bin/bash', username));
(`check_call` is a convenience method, it raises an exception if the exit code is not 0)<|eor|><|sor|>I would say using shell execute functions in any language is usually the sign of either a bad, or a lazy programmer.
It's generally not portable, opens up a wasp nest of security issues, and the output is often hard to process correctly.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | infinull | cbwsaca | <|sols|><|sot|>[from r/PHP] Creating a user from the web problem.<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/1l7baq/creating_a_user_from_the_web_problem/<|eol|><|sor|>Why. Oh god why.
I need a drink.<|eor|><|sor|>I mean..I know it's not making fun of PHP specifically and you can easily do something that horrific if other languages but....I think this still deserves to be up here.
I think I need a drink too...and also someone needs to stab me in the eye with an ice pick. <|eor|><|sor|>It's much harder in Python (for example) though, you have to pass in each argument as an iterable (unless you do shell=True... which you shouldn't usually.)
from subprocess import check_call
check_call(('/usr/bin/sudo', 'useradd', '-p', encpass, '-g', 'groupname', '-s', '/bin/bash', username));
(`check_call` is a convenience method, it raises an exception if the exit code is not 0)<|eor|><|eols|><|endoftext|> | 12 |
lolphp | djsumdog | cbws1z0 | <|sols|><|sot|>[from r/PHP] Creating a user from the web problem.<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/1l7baq/creating_a_user_from_the_web_problem/<|eol|><|sor|>Why. Oh god why.
I need a drink.<|eor|><|sor|>I mean..I know it's not making fun of PHP specifically and you can easily do something that horrific if other languages but....I think this still deserves to be up here.
I think I need a drink too...and also someone needs to stab me in the eye with an ice pick. <|eor|><|eols|><|endoftext|> | 10 |
lolphp | PasswordIsntHAMSTER | cbx48jd | <|sols|><|sot|>[from r/PHP] Creating a user from the web problem.<|eot|><|sol|>http://www.reddit.com/r/PHP/comments/1l7baq/creating_a_user_from_the_web_problem/<|eol|><|sor|>Not exactly a lolphp, more a "lol incompetent idiots programming".<|eor|><|sor|>Which seems more prevalent with PHP<|eor|><|eols|><|endoftext|> | 5 |
lolphp | RainOnYourTirade | 36s7nd | <|sols|><|sot|>Boolean return values are so inconsistent that they summoned Zalgo to php.net<|eot|><|sol|>http://i.imgur.com/i6GWf0l.jpg<|eol|><|eols|><|endoftext|> | 108 |
lolphp | idmontie | crgozzf | <|sols|><|sot|>Boolean return values are so inconsistent that they summoned Zalgo to php.net<|eot|><|sol|>http://i.imgur.com/i6GWf0l.jpg<|eol|><|sor|>At least it doesn't return 1 for failure and 0 for success. As we know, PHP does like to be consistent.<|eor|><|eols|><|endoftext|> | 30 |
lolphp | barubary | crheyjh | <|sols|><|sot|>Boolean return values are so inconsistent that they summoned Zalgo to php.net<|eot|><|sol|>http://i.imgur.com/i6GWf0l.jpg<|eol|><|sor|>At least it doesn't return 1 for failure and 0 for success. As we know, PHP does like to be consistent.<|eor|><|sor|>Or null for failure, even though null is also a valid return value as well, like json_decode.<|eor|><|sor|>so you have to do
json_decode("[$json_str]");
big fucking deal :)<|eor|><|sor|>But `json_decode("True")` is `true` whereas `json_decode("[True]")` is `null`. On the other hand, `json_decode("true ")` is `null` whereas `json_decode("[true ]")` is `array(true)`.
(This is all very version dependent. On some versions of PHP `json_decode("true ")` is `"true "`, for example.)<|eor|><|eols|><|endoftext|> | 19 |
lolphp | UristMasterRace | crgr8m5 | <|sols|><|sot|>Boolean return values are so inconsistent that they summoned Zalgo to php.net<|eot|><|sol|>http://i.imgur.com/i6GWf0l.jpg<|eol|><|sor|>Thus decreed the Old Gods
that PHP would be the tongue
of He who Waits Behind The Wall.
ZALGO!<|eor|><|eols|><|endoftext|> | 15 |
lolphp | youstolemyname | crgqcak | <|sols|><|sot|>Boolean return values are so inconsistent that they summoned Zalgo to php.net<|eot|><|sol|>http://i.imgur.com/i6GWf0l.jpg<|eol|><|sor|>Where are you seeing this? Link?<|eor|><|sor|>http://php.net/manual/en/function.xml-parse-into-struct.php<|eor|><|eols|><|endoftext|> | 7 |
lolphp | ZiggyTheHamster | crhklvn | <|sols|><|sot|>Boolean return values are so inconsistent that they summoned Zalgo to php.net<|eot|><|sol|>http://i.imgur.com/i6GWf0l.jpg<|eol|><|sor|>At least it doesn't return 1 for failure and 0 for success. As we know, PHP does like to be consistent.<|eor|><|sor|>Or null for failure, even though null is also a valid return value as well, like json_decode.<|eor|><|sor|>so you have to do
json_decode("[$json_str]");
big fucking deal :)<|eor|><|sor|>But `json_decode("True")` is `true` whereas `json_decode("[True]")` is `null`. On the other hand, `json_decode("true ")` is `null` whereas `json_decode("[true ]")` is `array(true)`.
(This is all very version dependent. On some versions of PHP `json_decode("true ")` is `"true "`, for example.)<|eor|><|sor|>you should still always check `json_error` because there are documented instances where it'll maybe parse some data but then die halfway through and you wouldn't know otherwise<|eor|><|eols|><|endoftext|> | 6 |
lolphp | RainOnYourTirade | crgrrom | <|sols|><|sot|>Boolean return values are so inconsistent that they summoned Zalgo to php.net<|eot|><|sol|>http://i.imgur.com/i6GWf0l.jpg<|eol|><|sor|>Where are you seeing this? Link?<|eor|><|sor|>http://php.net/manual/en/function.xml-parse-into-struct.php<|eor|><|soopr|>Bingo<|eoopr|><|sor|>Is it still Zalgo'd for you? I don't see it.<|eor|><|soopr|>Actually no, it looks like it's fixed now. Might have just been temporary.<|eoopr|><|eols|><|endoftext|> | 5 |
lolphp | polish_niceguy | 2wse9i | <|sols|><|sot|>Just ran into this one. PHP backward compatibility at its finest.<|eot|><|sol|>http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines<|eol|><|eols|><|endoftext|> | 110 |
lolphp | McGlockenshire | cotqm3z | <|sols|><|sot|>Just ran into this one. PHP backward compatibility at its finest.<|eot|><|sol|>http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines<|eol|><|sor|>There are two parts about this that make it *exceptionally* infuriating.
1. *All* processed input is mangled in this way. Not just $_GET, not just $_POST, but also $_COOKIE. I got bit by the cookie one a while ago.
2. It was only needed because of `register_globals`, but we're going to be stuck with it *forever*.<|eor|><|eols|><|endoftext|> | 37 |
lolphp | vytah | cotugja | <|sols|><|sot|>Just ran into this one. PHP backward compatibility at its finest.<|eot|><|sol|>http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines<|eol|><|sor|>So I was thinking, even when register_globals was a thing, why mangle the values on input? Why not do that in a function like [extract](http://php.net/extract) and keep the array keys what they are?
Then I thought, "I wonder what extract does with variable names that wouldn't work?"
[http://3v4l.org/N3hDr](http://3v4l.org/N3hDr)
No warnings, no errors, just silently ignores them. So why didn't register_globals just not make variables that didn't have valid names? Goddamn it<|eor|><|sor|>Hahahah, you expected consistency.<|eor|><|eols|><|endoftext|> | 34 |
lolphp | sloat | cotstn9 | <|sols|><|sot|>Just ran into this one. PHP backward compatibility at its finest.<|eot|><|sol|>http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines<|eol|><|sor|>So I was thinking, even when register_globals was a thing, why mangle the values on input? Why not do that in a function like [extract](http://php.net/extract) and keep the array keys what they are?
Then I thought, "I wonder what extract does with variable names that wouldn't work?"
[http://3v4l.org/N3hDr](http://3v4l.org/N3hDr)
No warnings, no errors, just silently ignores them. So why didn't register_globals just not make variables that didn't have valid names? Goddamn it<|eor|><|eols|><|endoftext|> | 23 |
lolphp | polish_niceguy | cotz1re | <|sols|><|sot|>Just ran into this one. PHP backward compatibility at its finest.<|eot|><|sol|>http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines<|eol|><|sor|>There are two parts about this that make it *exceptionally* infuriating.
1. *All* processed input is mangled in this way. Not just $_GET, not just $_POST, but also $_COOKIE. I got bit by the cookie one a while ago.
2. It was only needed because of `register_globals`, but we're going to be stuck with it *forever*.<|eor|><|soopr|>Even this workaround is totally non-consistent.
If it was supposed to help with `register_globals` then why it doesn't mangle keys starting with digits? They are also obviously invalid variable names. Just imagine the level of FUBAR it would introduce.<|eoopr|><|eols|><|endoftext|> | 20 |
lolphp | polish_niceguy | couf03l | <|sols|><|sot|>Just ran into this one. PHP backward compatibility at its finest.<|eot|><|sol|>http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines<|eol|><|sor|>But let's be honest, if you're using spaces in variable names you're stupid<|eor|><|soopr|>Request variables are not PHP variables and I don't see why I couldn't use any characters which are valid in array keys.<|eoopr|><|eols|><|endoftext|> | 11 |
lolphp | polish_niceguy | cotz5jg | <|sols|><|sot|>Just ran into this one. PHP backward compatibility at its finest.<|eot|><|sol|>http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines<|eol|><|sor|>So I was thinking, even when register_globals was a thing, why mangle the values on input? Why not do that in a function like [extract](http://php.net/extract) and keep the array keys what they are?
Then I thought, "I wonder what extract does with variable names that wouldn't work?"
[http://3v4l.org/N3hDr](http://3v4l.org/N3hDr)
No warnings, no errors, just silently ignores them. So why didn't register_globals just not make variables that didn't have valid names? Goddamn it<|eor|><|sor|>Except those are invalid *identifiers*, not *variable names*, you could access these with something like `${"color.box"}`
\#justPHPthings<|eor|><|soopr|>`extract()` doesn't care:
http://3v4l.org/rWKTJ<|eoopr|><|eols|><|endoftext|> | 11 |
lolphp | greyphilosopher | couhq1b | <|sols|><|sot|>Just ran into this one. PHP backward compatibility at its finest.<|eot|><|sol|>http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines<|eol|><|sor|>So not only are the values mangled, they are mangled in a many-to-one way that is impossible to reverse definitively. Fantastic.<|eor|><|sor|>I love that one comment suggested unmangling, as if the many-to-one issue doesn't exist<|eor|><|eols|><|endoftext|> | 6 |
lolphp | turtlekitty2084 | cow3ajt | <|sols|><|sot|>Just ran into this one. PHP backward compatibility at its finest.<|eot|><|sol|>http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines<|eol|><|sor|>This is gold.<|eor|><|eols|><|endoftext|> | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.