subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
duhruh
2ney2n
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|eols|><|endoftext|>
28
lolphp
implicit_cast
cmd6yrc
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>It seems dumb, it's not really. By default, you're in the global/root namespace (i.e. `\`), so namespace-relative class names, constant names and function names work. You need to qualify names from other namespaces, though. If you use `namespace` at the top of the file, you're no longer in the root namespace, you're in whatever namespace you specified. Thus, things like `Exception` aren't in the same namespace now and you must explicitly qualify your references, e.g. `\Exception`. To put it another way, think of the `namespace` keyword being like `cd`. You start out in `\`, which contains most of PHP's built-in stuff like `\Exception`. I can reference it with just `Exception` as I'm currently in `\` so it'll find it, but its fully-qualified absolute path is `\Exception`. But if I do `namespace foo\bar`, I'm now in `\foo\bar`. Relative references like `Exception` now resolve to `\foo\bar\Exception`... which doesn't exist. So, If I want the one in the root namespace, I need to do `\Exception`. In this way, I suppose `\` actually makes a lot of sense as a namespace separator.<|eor|><|sor|>A really important measure of any programming language is what happens when an author makes a mistake. It's very good if a particular error produces a malformed program that refuses to start. It's very, very bad if the mistake produces a program that does the right thing 99% of the time, but fails horribly in other cases. This mistake will be shipped and end-users will get unwanted QA work.<|eor|><|eols|><|endoftext|>
13
lolphp
frazzlet
cmd480c
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>Does this apply to all types? E.g. if I specify a type, such as a class when constructing it, do I have to type \ in front of it as well? Or does it only pertain to exceptions?<|eor|><|sor|>If you're working within a namespace, all classes need a backslash in front (or a use statement) apart from the classes within the same namespace.<|eor|><|eols|><|endoftext|>
11
lolphp
myaut
cmde67k
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>Looks like PHP developers adopted C++ approach, but due to limitations of "dynamicness" they couldn't do it fine. In C++ class name without T_PAAMAYIM_NEKUDOTAYIM qualifiers would be searched in global namespace, but you may restrict searching to global namespace using ::ClassName. A traditional form without colons is more like conformity with earlier C/C++. But, C++ always knows which classes are in global namespace, and in PHP, simple eval() may blow this assumption up. They had to implement i.e. Python approach: seek for a class definition every time catch is checked with clear scoping rules, but like always they followed "fine like this" idiom.<|eor|><|eols|><|endoftext|>
10
lolphp
phoshi
cmdep85
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>It seems dumb, it's not really. By default, you're in the global/root namespace (i.e. `\`), so namespace-relative class names, constant names and function names work. You need to qualify names from other namespaces, though. If you use `namespace` at the top of the file, you're no longer in the root namespace, you're in whatever namespace you specified. Thus, things like `Exception` aren't in the same namespace now and you must explicitly qualify your references, e.g. `\Exception`. To put it another way, think of the `namespace` keyword being like `cd`. You start out in `\`, which contains most of PHP's built-in stuff like `\Exception`. I can reference it with just `Exception` as I'm currently in `\` so it'll find it, but its fully-qualified absolute path is `\Exception`. But if I do `namespace foo\bar`, I'm now in `\foo\bar`. Relative references like `Exception` now resolve to `\foo\bar\Exception`... which doesn't exist. So, If I want the one in the root namespace, I need to do `\Exception`. In this way, I suppose `\` actually makes a lot of sense as a namespace separator.<|eor|><|soopr|>This is dumb, and I'll tell you why. In a proper programming language scope is handled more elegantly, we look at the current scope/namespace and if we cannot find the class in question we look at the next namespace up, all the way to the global scope/namespace till we resolve the class or we get an undefined, especially when you are dealing with such a core class as Exception one would expect for this to be available in any namespace. PHP doesn't even give you a indication that the class Exception is not defined when trying to catch it, the catch statement is just skipped over. If you think this makes sense in any way please pick up a programming language design book.<|eoopr|><|sor|>> In a proper programming language scope is handled more elegantly, we look at the current scope/namespace and if we cannot find the class in question we look at the next namespace up, all the way to the global scope/namespace till we resolve the class or we get an undefined That means you need to call the autoloader several times. That's not really ideal. Although, do other languages scope their namespaces like this? I admit I've mostly used dynamic languages, so I'm not sure what, say, C++ or C# do here. **EDIT:** I think C# has nested namespaces, but what PHP has isn't really namespace *nesting*, it's more like sub-namespaces. I don't believe there's really much difference between `namespace Foo_Bar` and `namespace Foo\Bar` when it comes down to it, I don't think we assign a special meaning to the backslashes in the middle, that's the job of autoloaders. > PHP doesn't even give you a indication that the class Exception is not defined when trying to catch it, the catch statement is just skipped over. This is presumably to avoid having to run the autoloader, which is expensive. You could give an indication it's not defined, but that'd entail running the autoloader for every single try/catch block with a class name at script startup. For the same reasons, PHP doesn't check class names used in type hints on function parameters, as that would also require running the autoloader.<|eor|><|sor|>I don't really care about the technical reasons. Other languages manage to have very similar behaviour without this problem. As it is, this is just throwing one more gotcha onto the pile of gotchas that is php. <|eor|><|eols|><|endoftext|>
10
lolphp
nikomo
cmd1hbd
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>Jesus effin Christ, high level languages are supposed to make the programmer's job less painful, not more painful. <|eor|><|eols|><|endoftext|>
9
lolphp
berkes
cmdefvj
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>So you're posting an article from 5 years ago? About a feature that's well known? About a use case that is easy to understand? And easy to avoid? And explained thoroughly? Got it. <|eor|><|sor|>I did not know about it. And was truly surprised by the poor design choises here. Probably because I hardly ever program in PHP anymore, like many people in this sub, most likely.<|eor|><|eols|><|endoftext|>
9
lolphp
implicit_cast
cmdamcu
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>It seems dumb, it's not really. By default, you're in the global/root namespace (i.e. `\`), so namespace-relative class names, constant names and function names work. You need to qualify names from other namespaces, though. If you use `namespace` at the top of the file, you're no longer in the root namespace, you're in whatever namespace you specified. Thus, things like `Exception` aren't in the same namespace now and you must explicitly qualify your references, e.g. `\Exception`. To put it another way, think of the `namespace` keyword being like `cd`. You start out in `\`, which contains most of PHP's built-in stuff like `\Exception`. I can reference it with just `Exception` as I'm currently in `\` so it'll find it, but its fully-qualified absolute path is `\Exception`. But if I do `namespace foo\bar`, I'm now in `\foo\bar`. Relative references like `Exception` now resolve to `\foo\bar\Exception`... which doesn't exist. So, If I want the one in the root namespace, I need to do `\Exception`. In this way, I suppose `\` actually makes a lot of sense as a namespace separator.<|eor|><|sor|>A really important measure of any programming language is what happens when an author makes a mistake. It's very good if a particular error produces a malformed program that refuses to start. It's very, very bad if the mistake produces a program that does the right thing 99% of the time, but fails horribly in other cases. This mistake will be shipped and end-users will get unwanted QA work.<|eor|><|sor|>> A really important measure of any programming language is what happens when an author makes a mistake. > > It's very good if a particular error produces a malformed program that refuses to start. Yes, that's true. But certain types of error checks impose a very large overhead. If we were to check that classes used in type hints existed, we'd need to trigger an autoload to validate every type hint, leading to almost every class in a library being loaded, and completely defeating the point of autoloading. I assume that it's for similar reasons that PHP doesn't check exception classes exist in catch statements.<|eor|><|sor|>Right. It's a tradeoff. Why, though? This isn't essential to computation. The autoloader is a hack to paper over performance problems that arose from bad design. Most programming languages get along without an "autoloader" concept, and most languages with type annotations don't have this problem.<|eor|><|eols|><|endoftext|>
7
lolphp
himdel
cmdvx3j
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>It feels weird only when you use Exception because that feels like it should be available everywhere. Try substituting MyException and suddenly it feels *very* right and completely logical. IMHO the real wtf is that you can't just write `catch($e)`.<|eor|><|eols|><|endoftext|>
6
lolphp
OneWingedShark
cmem0fn
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>Jesus effin Christ, high level languages are supposed to make the programmer's job less painful, not more painful. <|eor|><|sor|>Ohhh, thank you for the new bacronym for PHP: ***Painfully Horrible Programming***<|eor|><|eols|><|endoftext|>
6
lolphp
phoshi
cmdhjgk
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>It seems dumb, it's not really. By default, you're in the global/root namespace (i.e. `\`), so namespace-relative class names, constant names and function names work. You need to qualify names from other namespaces, though. If you use `namespace` at the top of the file, you're no longer in the root namespace, you're in whatever namespace you specified. Thus, things like `Exception` aren't in the same namespace now and you must explicitly qualify your references, e.g. `\Exception`. To put it another way, think of the `namespace` keyword being like `cd`. You start out in `\`, which contains most of PHP's built-in stuff like `\Exception`. I can reference it with just `Exception` as I'm currently in `\` so it'll find it, but its fully-qualified absolute path is `\Exception`. But if I do `namespace foo\bar`, I'm now in `\foo\bar`. Relative references like `Exception` now resolve to `\foo\bar\Exception`... which doesn't exist. So, If I want the one in the root namespace, I need to do `\Exception`. In this way, I suppose `\` actually makes a lot of sense as a namespace separator.<|eor|><|soopr|>This is dumb, and I'll tell you why. In a proper programming language scope is handled more elegantly, we look at the current scope/namespace and if we cannot find the class in question we look at the next namespace up, all the way to the global scope/namespace till we resolve the class or we get an undefined, especially when you are dealing with such a core class as Exception one would expect for this to be available in any namespace. PHP doesn't even give you a indication that the class Exception is not defined when trying to catch it, the catch statement is just skipped over. If you think this makes sense in any way please pick up a programming language design book.<|eoopr|><|sor|>> In a proper programming language scope is handled more elegantly, we look at the current scope/namespace and if we cannot find the class in question we look at the next namespace up, all the way to the global scope/namespace till we resolve the class or we get an undefined That means you need to call the autoloader several times. That's not really ideal. Although, do other languages scope their namespaces like this? I admit I've mostly used dynamic languages, so I'm not sure what, say, C++ or C# do here. **EDIT:** I think C# has nested namespaces, but what PHP has isn't really namespace *nesting*, it's more like sub-namespaces. I don't believe there's really much difference between `namespace Foo_Bar` and `namespace Foo\Bar` when it comes down to it, I don't think we assign a special meaning to the backslashes in the middle, that's the job of autoloaders. > PHP doesn't even give you a indication that the class Exception is not defined when trying to catch it, the catch statement is just skipped over. This is presumably to avoid having to run the autoloader, which is expensive. You could give an indication it's not defined, but that'd entail running the autoloader for every single try/catch block with a class name at script startup. For the same reasons, PHP doesn't check class names used in type hints on function parameters, as that would also require running the autoloader.<|eor|><|sor|>I don't really care about the technical reasons. Other languages manage to have very similar behaviour without this problem. As it is, this is just throwing one more gotcha onto the pile of gotchas that is php. <|eor|><|sor|>Other languages are compiled ahead of time, or suffer from the performance cost of loading the entire program at startup.<|eor|><|sor|>If we exclude every AOT language then we still have many languages that support namespaces or similar and do not exhibit this absurd behaviour. A "performance cost" in this case is an artefact of the implementation, which again, is a detail that I don't care about. There is zero technical reason why you couldn't have sane behaviour here, but PHP doesn't manage it because it needs a very leaky optimisation. That is a gotcha. It is practically the definition of a gotcha.<|eor|><|sor|>No, you could have "sane" behaviour and nest the namespaces, but you'd throw away any performance benefits. Although I'm unaware of any languages that have this "sane" behaviour.<|eor|><|sor|>Take Python as one example, the namespace for language fundamentals is implicitly loaded everywhere. The choice is not between "Make basic types unavailable" and "Suffer serious performance impacts", the choice is between a good design and a bad one. The good design is the one which does not *unload fundamental language types*.<|eor|><|eols|><|endoftext|>
6
lolphp
duhruh
cmd62ww
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>It seems dumb, it's not really. By default, you're in the global/root namespace (i.e. `\`), so namespace-relative class names, constant names and function names work. You need to qualify names from other namespaces, though. If you use `namespace` at the top of the file, you're no longer in the root namespace, you're in whatever namespace you specified. Thus, things like `Exception` aren't in the same namespace now and you must explicitly qualify your references, e.g. `\Exception`. To put it another way, think of the `namespace` keyword being like `cd`. You start out in `\`, which contains most of PHP's built-in stuff like `\Exception`. I can reference it with just `Exception` as I'm currently in `\` so it'll find it, but its fully-qualified absolute path is `\Exception`. But if I do `namespace foo\bar`, I'm now in `\foo\bar`. Relative references like `Exception` now resolve to `\foo\bar\Exception`... which doesn't exist. So, If I want the one in the root namespace, I need to do `\Exception`. In this way, I suppose `\` actually makes a lot of sense as a namespace separator.<|eor|><|soopr|>This is dumb, and I'll tell you why. In a proper programming language scope is handled more elegantly, we look at the current scope/namespace and if we cannot find the class in question we look at the next namespace up, all the way to the global scope/namespace till we resolve the class or we get an undefined, especially when you are dealing with such a core class as Exception one would expect for this to be available in any namespace. PHP doesn't even give you a indication that the class Exception is not defined when trying to catch it, the catch statement is just skipped over. If you think this makes sense in any way please pick up a programming language design book.<|eoopr|><|eols|><|endoftext|>
5
lolphp
phoshi
cmdgzmx
<|sols|><|sot|>Exception in a namespace is not defined -_-<|eot|><|sol|>http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/<|eol|><|sor|>It seems dumb, it's not really. By default, you're in the global/root namespace (i.e. `\`), so namespace-relative class names, constant names and function names work. You need to qualify names from other namespaces, though. If you use `namespace` at the top of the file, you're no longer in the root namespace, you're in whatever namespace you specified. Thus, things like `Exception` aren't in the same namespace now and you must explicitly qualify your references, e.g. `\Exception`. To put it another way, think of the `namespace` keyword being like `cd`. You start out in `\`, which contains most of PHP's built-in stuff like `\Exception`. I can reference it with just `Exception` as I'm currently in `\` so it'll find it, but its fully-qualified absolute path is `\Exception`. But if I do `namespace foo\bar`, I'm now in `\foo\bar`. Relative references like `Exception` now resolve to `\foo\bar\Exception`... which doesn't exist. So, If I want the one in the root namespace, I need to do `\Exception`. In this way, I suppose `\` actually makes a lot of sense as a namespace separator.<|eor|><|soopr|>This is dumb, and I'll tell you why. In a proper programming language scope is handled more elegantly, we look at the current scope/namespace and if we cannot find the class in question we look at the next namespace up, all the way to the global scope/namespace till we resolve the class or we get an undefined, especially when you are dealing with such a core class as Exception one would expect for this to be available in any namespace. PHP doesn't even give you a indication that the class Exception is not defined when trying to catch it, the catch statement is just skipped over. If you think this makes sense in any way please pick up a programming language design book.<|eoopr|><|sor|>> In a proper programming language scope is handled more elegantly, we look at the current scope/namespace and if we cannot find the class in question we look at the next namespace up, all the way to the global scope/namespace till we resolve the class or we get an undefined That means you need to call the autoloader several times. That's not really ideal. Although, do other languages scope their namespaces like this? I admit I've mostly used dynamic languages, so I'm not sure what, say, C++ or C# do here. **EDIT:** I think C# has nested namespaces, but what PHP has isn't really namespace *nesting*, it's more like sub-namespaces. I don't believe there's really much difference between `namespace Foo_Bar` and `namespace Foo\Bar` when it comes down to it, I don't think we assign a special meaning to the backslashes in the middle, that's the job of autoloaders. > PHP doesn't even give you a indication that the class Exception is not defined when trying to catch it, the catch statement is just skipped over. This is presumably to avoid having to run the autoloader, which is expensive. You could give an indication it's not defined, but that'd entail running the autoloader for every single try/catch block with a class name at script startup. For the same reasons, PHP doesn't check class names used in type hints on function parameters, as that would also require running the autoloader.<|eor|><|sor|>I don't really care about the technical reasons. Other languages manage to have very similar behaviour without this problem. As it is, this is just throwing one more gotcha onto the pile of gotchas that is php. <|eor|><|sor|>Other languages are compiled ahead of time, or suffer from the performance cost of loading the entire program at startup.<|eor|><|sor|>If we exclude every AOT language then we still have many languages that support namespaces or similar and do not exhibit this absurd behaviour. A "performance cost" in this case is an artefact of the implementation, which again, is a detail that I don't care about. There is zero technical reason why you couldn't have sane behaviour here, but PHP doesn't manage it because it needs a very leaky optimisation. That is a gotcha. It is practically the definition of a gotcha.<|eor|><|eols|><|endoftext|>
5
lolphp
catcradle5
26ngjt
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|eols|><|endoftext|>
24
lolphp
phoshi
chsy4nu
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>The problem with "designed for the web" is that the only place php 'shines' there is having an inbuilt templating engine. Unfortunately, that genre of ultra flexible templating engine is widely considered a bad idea, and the majority of popular templating engines these days go the route of limiting power to make it easier to keep your layout and logic separated. Even templating engines /for/ php do this. In every other area, php wasn't designed. Comparing it to c#, which is possibly one of the better made languages available today, is... Not something I would agree with. <|eor|><|eols|><|endoftext|>
24
lolphp
alx5000
chsr6hr
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|soopr|>I just find it humorous that they seem to value spending so much effort on optimizing Zend and making internal, private API changes a lot more than doing anything to the public APIs.<|eoopr|><|sor|> - Kids. From now on there are three ways of doing things: the right way, the wrong way, and the phpng way. - Isn't that the wrong way? - Yes, but faster! <|eor|><|eols|><|endoftext|>
21
lolphp
_vec_
chsx8ev
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>> Part of what makes PHP lovely I think you might be in the wrong subreddit...<|eor|><|eols|><|endoftext|>
13
lolphp
merreborn
chtidiu
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>> 20% more throughput 20% more of a small number is still a small number :D<|eor|><|sor|>Sure. But when you're already married to a PHP application, you'll take 20% anywhere you can get it. I've done PHP upgrades twice for exactly this reason (5.2 to 5.3, and 5.3 to 5.5). The "free" 10-30% performance boost was very welcome. Upgrading PHP is much easier than changing a large PHP application. Hell, sometimes *writing* a faster PHP interpreter is easier than changing a large PHP application... which is how HipHop/HHVM came to be. And hey, when you've got 100 apache servers running your PHP code, being able to shut 20% of them down is a measurable savings... <|eor|><|eols|><|endoftext|>
9
lolphp
Turtlecupcakes
chsxc72
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>> Part of what makes PHP lovely I think you might be in the wrong subreddit...<|eor|><|sor|>Nah, the lol parts of PHP make it great, too.<|eor|><|eols|><|endoftext|>
9
lolphp
phoshi
chszfqa
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>The problem with "designed for the web" is that the only place php 'shines' there is having an inbuilt templating engine. Unfortunately, that genre of ultra flexible templating engine is widely considered a bad idea, and the majority of popular templating engines these days go the route of limiting power to make it easier to keep your layout and logic separated. Even templating engines /for/ php do this. In every other area, php wasn't designed. Comparing it to c#, which is possibly one of the better made languages available today, is... Not something I would agree with. <|eor|><|sor|>It's also the fact that you can just make a new file, and boom, there is your next web page on your site. No faffing about with MVC this or MVVP that, no views, no controllers, just write it all out and you're done. Of course that is a terrible practice as it can quickly spiral out of control, but it appeals to new web programmers.<|eor|><|sor|>Most languages can offer something like that. If you have a python cgi handler, for example, you can just make a new python file and use that. What PHP offers there is the ability to add small things to a html file without needing to restructure the page. This is a good thing if you want to add a readout of the current server time, or maybe a hit counter, but on anything non-trivial it's not a serious consideration. <|eor|><|eols|><|endoftext|>
9
lolphp
rbnc
chszrni
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>The problem with "designed for the web" is that the only place php 'shines' there is having an inbuilt templating engine. Unfortunately, that genre of ultra flexible templating engine is widely considered a bad idea, and the majority of popular templating engines these days go the route of limiting power to make it easier to keep your layout and logic separated. Even templating engines /for/ php do this. In every other area, php wasn't designed. Comparing it to c#, which is possibly one of the better made languages available today, is... Not something I would agree with. <|eor|><|sor|>It's also the fact that you can just make a new file, and boom, there is your next web page on your site. No faffing about with MVC this or MVVP that, no views, no controllers, just write it all out and you're done. Of course that is a terrible practice as it can quickly spiral out of control, but it appeals to new web programmers.<|eor|><|sor|>You're confusing frameworks and languages.<|eor|><|sor|>How so?<|eor|><|sor|>As far as I know there are no MVC languages, the MVC implementations being discussed above in Ruby and Python are framework level. Pure Perl, Python and or allow you to to create a file and simply execute it without any views/controllers etc if your server is configured correctly.<|eor|><|eols|><|endoftext|>
9
lolphp
phoshi
chtwhe3
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>The problem with "designed for the web" is that the only place php 'shines' there is having an inbuilt templating engine. Unfortunately, that genre of ultra flexible templating engine is widely considered a bad idea, and the majority of popular templating engines these days go the route of limiting power to make it easier to keep your layout and logic separated. Even templating engines /for/ php do this. In every other area, php wasn't designed. Comparing it to c#, which is possibly one of the better made languages available today, is... Not something I would agree with. <|eor|><|sor|>It's also the fact that you can just make a new file, and boom, there is your next web page on your site. No faffing about with MVC this or MVVP that, no views, no controllers, just write it all out and you're done. Of course that is a terrible practice as it can quickly spiral out of control, but it appeals to new web programmers.<|eor|><|sor|>Most languages can offer something like that. If you have a python cgi handler, for example, you can just make a new python file and use that. What PHP offers there is the ability to add small things to a html file without needing to restructure the page. This is a good thing if you want to add a readout of the current server time, or maybe a hit counter, but on anything non-trivial it's not a serious consideration. <|eor|><|sor|>While most language *can*, it *does not*. Default matters.<|eor|><|sor|>Yes, yes it does. It's right there in the standard library. So you need a cgi handler and webserver--the same is true of php (or an apache and mod_php)--and then you can just execute files by pointing your browser at it. Just like php. People don't do it because it's not actually a very good idea. <|eor|><|sor|>Like I said, default matters. It's right in the standard library, but is it taught to newbie right from the start to do it that way? No. Is the first step of most Python tutorial to drop index.py file in Apache and print out some web page like PHP tutorial? No. Default matters, culture matters. > People don't do it because it's not actually a very good idea. Good idea or not, people do it in PHP, and people don't do it in Python. Even my grandparent post saying: > Of course that is a terrible practice as it can quickly spiral out of control, but it appeals to new web programmers. he even admit that it's a bad practice. But the point is that it is what PHP presents to new programmer *by default*. I don't know why people down-vote me and him for stating the fact.<|eor|><|sor|>Right, but at that point your argument has become a tautology. PHP is used this way because PHP is used this way, python is not used this way because python is not used this way. That doesn't /mean/ anything. Both are fully capable of it, both can do it trivially out of the box. Even on many bottom of the barrel shared hosts you can have python support. PHP is used here because people use PHP here, and most of them don't seem to know there are alternatives. I don't believe there's anything inherent to the language, and we already know php's culture is bankrupt. <|eor|><|eols|><|endoftext|>
9
lolphp
catcradle5
chsntjh
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|soopr|>I just find it humorous that they seem to value spending so much effort on optimizing Zend and making internal, private API changes a lot more than doing anything to the public APIs.<|eoopr|><|eols|><|endoftext|>
8
lolphp
Turtlecupcakes
chswpem
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|eols|><|endoftext|>
8
lolphp
cbraga
chtgqy3
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|soopr|>I just find it humorous that they seem to value spending so much effort on optimizing Zend and making internal, private API changes a lot more than doing anything to the public APIs.<|eoopr|><|sor|>It'd be nice to have a sane, ubiquitous and fast server engine under the hood, even if it primarily implements an insane language. If the server engine can be sufficiently decoupled from the public PHP API, it could end up being a decent and widely used CGI platform for development in all languages.<|eor|><|sor|>Or, you know, they could use one of the multitude of jit backends already available such as java, .net, parrot (perl), etc instead of reinventing another wheel that will turn out to be kinda square.<|eor|><|eols|><|endoftext|>
7
lolphp
phoshi
chttw01
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>The problem with "designed for the web" is that the only place php 'shines' there is having an inbuilt templating engine. Unfortunately, that genre of ultra flexible templating engine is widely considered a bad idea, and the majority of popular templating engines these days go the route of limiting power to make it easier to keep your layout and logic separated. Even templating engines /for/ php do this. In every other area, php wasn't designed. Comparing it to c#, which is possibly one of the better made languages available today, is... Not something I would agree with. <|eor|><|sor|>It's also the fact that you can just make a new file, and boom, there is your next web page on your site. No faffing about with MVC this or MVVP that, no views, no controllers, just write it all out and you're done. Of course that is a terrible practice as it can quickly spiral out of control, but it appeals to new web programmers.<|eor|><|sor|>Most languages can offer something like that. If you have a python cgi handler, for example, you can just make a new python file and use that. What PHP offers there is the ability to add small things to a html file without needing to restructure the page. This is a good thing if you want to add a readout of the current server time, or maybe a hit counter, but on anything non-trivial it's not a serious consideration. <|eor|><|sor|>While most language *can*, it *does not*. Default matters.<|eor|><|sor|>Yes, yes it does. It's right there in the standard library. So you need a cgi handler and webserver--the same is true of php (or an apache and mod_php)--and then you can just execute files by pointing your browser at it. Just like php. People don't do it because it's not actually a very good idea. <|eor|><|eols|><|endoftext|>
6
lolphp
Banane9
chsv16f
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>> 20% more throughput 20% more of a small number is still a small number :D<|eor|><|eols|><|endoftext|>
5
lolphp
Psychocist
chwauqu
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I cannot believe people actually stand up to defend PHP. Seeing these comments worries me. It reminds me of fundamentalist Christians, and PHP is their Jesus. I can only assume that any developer who defends PHP has only ever worked with PHP (or much, much worse, somehow).<|eor|><|eols|><|endoftext|>
5
lolphp
terrorobe
chsyaj5
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>> Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. ...and runs like shit without an op-code cacher. Your point being? ;) <|eor|><|eols|><|endoftext|>
5
lolphp
rbnc
chszidf
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>[deleted]<|eor|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>The problem with "designed for the web" is that the only place php 'shines' there is having an inbuilt templating engine. Unfortunately, that genre of ultra flexible templating engine is widely considered a bad idea, and the majority of popular templating engines these days go the route of limiting power to make it easier to keep your layout and logic separated. Even templating engines /for/ php do this. In every other area, php wasn't designed. Comparing it to c#, which is possibly one of the better made languages available today, is... Not something I would agree with. <|eor|><|sor|>It's also the fact that you can just make a new file, and boom, there is your next web page on your site. No faffing about with MVC this or MVVP that, no views, no controllers, just write it all out and you're done. Of course that is a terrible practice as it can quickly spiral out of control, but it appeals to new web programmers.<|eor|><|sor|>You're confusing frameworks and languages.<|eor|><|eols|><|endoftext|>
5
lolphp
rbnc
cht0mqs
<|sols|><|sot|>PHP Next Generation: Performance gains and internal API changes will finally fix PHP!<|eot|><|sol|>http://www.php.net/archive/2014.php#id2014-05-27-1<|eol|><|sor|>I don't know about that, Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled. Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks. To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.<|eor|><|sor|>The problem with "designed for the web" is that the only place php 'shines' there is having an inbuilt templating engine. Unfortunately, that genre of ultra flexible templating engine is widely considered a bad idea, and the majority of popular templating engines these days go the route of limiting power to make it easier to keep your layout and logic separated. Even templating engines /for/ php do this. In every other area, php wasn't designed. Comparing it to c#, which is possibly one of the better made languages available today, is... Not something I would agree with. <|eor|><|sor|>It's also the fact that you can just make a new file, and boom, there is your next web page on your site. No faffing about with MVC this or MVVP that, no views, no controllers, just write it all out and you're done. Of course that is a terrible practice as it can quickly spiral out of control, but it appeals to new web programmers.<|eor|><|sor|>You're confusing frameworks and languages.<|eor|><|sor|>How so?<|eor|><|sor|>As far as I know there are no MVC languages, the MVC implementations being discussed above in Ruby and Python are framework level. Pure Perl, Python and or allow you to to create a file and simply execute it without any views/controllers etc if your server is configured correctly.<|eor|><|sor|>I know this, and I didn't say there were MVC languages in my comment. Follow a guide on building a site with Ruby, and step 1 is to install Rails, Sinatra, or whatever. With Python, step 1 is to install Django or whatever. Step 2 is then learning how to do basic stuff in those frameworks, and then it's step 3 where you actually get to do stuff. The whole ethos with PHP avoids all of that. Step 1 is just make 'index.php' and stick your code in, go to localhost, and boom your site is running. That appeals a lot to new programmers who are just starting to learn. That was the point of my comment.<|eor|><|sor|>>The whole ethos with PHP avoids all of that. Step 1 is just make 'index.php' and stick your code in, go to localhost, and boom your site is running. This is the same with Ruby, Perl and Python if your server is configured correctly.<|eor|><|eols|><|endoftext|>
5
lolphp
siroki
2510dy
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|eols|><|endoftext|>
27
lolphp
Rhomboid
chcqg4o
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>This is hilarious. On POSIX systems, there is a [`gettimeofday()`](http://pubs.opengroup.org/onlinepubs/009695399/functions/gettimeofday.html) system call that fills in a struct containing two integers representing the number of integer seconds since the epoch, and the number of integer microseconds. It can also optionally fill in a second struct containing timezone information, but the way that information is represented is hopelessly naive and obsolete and all information about timezones has long been removed from the kernel and implemented via the Olson database in userspace. So it's pointless to request that this second struct is to be populated, and everyone passes the null pointer for that argument which means "don't bother." The POSIX spec even goes so far as to state that if you *don't* pass the null pointer for the second argument, the behavior is unspecified, which is a clear signal that no code should ever be trying to get timezone information from this API. Okay, so PHP provides [`gettimeofday()`](http://www.php.net/manual/en/function.gettimeofday.php) that faithfully mirrors that interface and returns an associative array containing the four fields of both structs. Naturally, it didn't get the memo that the timezone information is completely useless and obsolete, nor do they even bother to document it. But at least it returns the two integers unmolested. You could use this, but it takes a little work. Then some bright bulb must have noticed that it was a little awkward to use `gettimeofday()`, so they wrote `microtime()`, which apparently just calls `gettimeofday()` and rearranges the two returned integers into a format that is unequivocally useless. How does that make anything better? In version 5.0.0 an optional boolean parameter was added to `microtime()` to specify the desire for a floating point return value, and then in 5.1.0 (!!) an optional boolean parameter was added to `gettimeofday()` to specify the same thing. Why are there two functions? Why did it take an entire major release to realize that having the information as a floating point value might be useful from both functions? Moreover, why is PHP's standard library so unwilling to do anything but offer trivial wrappers around existing C functions? Shouldn't a time and date library have some kind of cohesive design behind it? What do you do in PHP if you don't want wall-clock time but a monotonic clock source? (The `gettimeofday()` syscall is deprecated in favor of `clock_gettime()` which has multiple time sources for this reason.) What do you do if you're running on a platform that isn't POSIX and doesn't have any such `gettimeofday()` syscall? Let's talk about that for a minute. The documentation for `microtime()` says: > This function is only available on operating systems that support the gettimeofday() system call. The documentation for `gettimeofday()` says: > This is an interface to gettimeofday(2). Let's put aside for a minute the inherent inconsistency in this wording: surely if one is available then both should be available. But `gettimeofday()` doesn't actually say what systems it's available on. Presumably any system without such a syscall cannot use these functions, right? Nope. There's a compatibility shim for Windows where there is no such syscall. So not only is this API designed around a particular platform-specific API, and not only does the documentation imply that it will only work on such platforms, but in fact it will work on systems without that syscall. Or at least Windows. If you run PHP on a non-POSIX non-Windows system, then you're screwed. In summary: Who in the hell is responsible for this horrible mess??!? <|eor|><|eols|><|endoftext|>
25
lolphp
Pixa
chclqw3
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>Dat string return value. Lolphp Gold. Why would anyone ever favour returning "0.1234 567" instead of 567.1234?<|eor|><|eols|><|endoftext|>
19
lolphp
ChoHag
chcmis4
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>Dat string return value. Lolphp Gold. Why would anyone ever favour returning "0.1234 567" instead of 567.1234?<|eor|><|sor|>I ... it does what? That's a special kind of special.<|eor|><|eols|><|endoftext|>
13
lolphp
bart2019
chd10cq
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>This is hilarious. On POSIX systems, there is a [`gettimeofday()`](http://pubs.opengroup.org/onlinepubs/009695399/functions/gettimeofday.html) system call that fills in a struct containing two integers representing the number of integer seconds since the epoch, and the number of integer microseconds. It can also optionally fill in a second struct containing timezone information, but the way that information is represented is hopelessly naive and obsolete and all information about timezones has long been removed from the kernel and implemented via the Olson database in userspace. So it's pointless to request that this second struct is to be populated, and everyone passes the null pointer for that argument which means "don't bother." The POSIX spec even goes so far as to state that if you *don't* pass the null pointer for the second argument, the behavior is unspecified, which is a clear signal that no code should ever be trying to get timezone information from this API. Okay, so PHP provides [`gettimeofday()`](http://www.php.net/manual/en/function.gettimeofday.php) that faithfully mirrors that interface and returns an associative array containing the four fields of both structs. Naturally, it didn't get the memo that the timezone information is completely useless and obsolete, nor do they even bother to document it. But at least it returns the two integers unmolested. You could use this, but it takes a little work. Then some bright bulb must have noticed that it was a little awkward to use `gettimeofday()`, so they wrote `microtime()`, which apparently just calls `gettimeofday()` and rearranges the two returned integers into a format that is unequivocally useless. How does that make anything better? In version 5.0.0 an optional boolean parameter was added to `microtime()` to specify the desire for a floating point return value, and then in 5.1.0 (!!) an optional boolean parameter was added to `gettimeofday()` to specify the same thing. Why are there two functions? Why did it take an entire major release to realize that having the information as a floating point value might be useful from both functions? Moreover, why is PHP's standard library so unwilling to do anything but offer trivial wrappers around existing C functions? Shouldn't a time and date library have some kind of cohesive design behind it? What do you do in PHP if you don't want wall-clock time but a monotonic clock source? (The `gettimeofday()` syscall is deprecated in favor of `clock_gettime()` which has multiple time sources for this reason.) What do you do if you're running on a platform that isn't POSIX and doesn't have any such `gettimeofday()` syscall? Let's talk about that for a minute. The documentation for `microtime()` says: > This function is only available on operating systems that support the gettimeofday() system call. The documentation for `gettimeofday()` says: > This is an interface to gettimeofday(2). Let's put aside for a minute the inherent inconsistency in this wording: surely if one is available then both should be available. But `gettimeofday()` doesn't actually say what systems it's available on. Presumably any system without such a syscall cannot use these functions, right? Nope. There's a compatibility shim for Windows where there is no such syscall. So not only is this API designed around a particular platform-specific API, and not only does the documentation imply that it will only work on such platforms, but in fact it will work on systems without that syscall. Or at least Windows. If you run PHP on a non-POSIX non-Windows system, then you're screwed. In summary: Who in the hell is responsible for this horrible mess??!? <|eor|><|sor|>> Who in the hell is responsible for this horrible mess??!? You said the key word: "responsible". I don't think in PHP anybody is responsible, for anything. Nowhere the age-old declaration about the software is more fitting than here: "no warranty of suitability for any particular purpose". If PHP does what you want: good for you. If it doesn't: tough luck. <|eor|><|eols|><|endoftext|>
11
lolphp
barubary
chd3vup
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>Dat string return value. Lolphp Gold. Why would anyone ever favour returning "0.1234 567" instead of 567.1234?<|eor|><|sor|>Well, because you can't exactly represent every microsecond as a unique float. You'll run into float rounding and get big blocks of consecutive microseconds that are equal to each other. You also can't just return a number of microseconds since the epoch because it can overflow an integer. The underlying C function returns a struct with an integer of seconds and an integer of microseconds within that second. Most other languages either return a `Time` object of some sort that internally uses the same two integer representation or return a microsecond timestamp as an arbitrary precision number. PHP, though, didn't have objects at the time this function was created. They still don't have a primitive arbitrary precision type. I can't remember where off the top of my head (and I don't care enough to go look it up) but I do know they use strings to represent arbitrary precision numbers at a few other places in the standard library. In general, that's probably the least bad way around the problem, but I'm not sure why they didn't just return a two-element array in this case.<|eor|><|sor|>It could just return a string of the form "567.1234". No precision is lost and it'll convert to a float when needed automatically (because PHP).<|eor|><|eols|><|endoftext|>
9
lolphp
siroki
chcl522
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|soopr|>> returns a string in the form "msec sec", [], and msec measures microseconds that have elapsed since sec and is also expressed in seconds So, I read msec as "milliseconds," but it turns out that's just microseconds (whew, so the name of the function IS correct somewhat) in seconds. OK, I understand it, but that's a very stupid way to explain it.<|eoopr|><|eols|><|endoftext|>
8
lolphp
OneWingedShark
chexglg
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>This is hilarious. On POSIX systems, there is a [`gettimeofday()`](http://pubs.opengroup.org/onlinepubs/009695399/functions/gettimeofday.html) system call that fills in a struct containing two integers representing the number of integer seconds since the epoch, and the number of integer microseconds. It can also optionally fill in a second struct containing timezone information, but the way that information is represented is hopelessly naive and obsolete and all information about timezones has long been removed from the kernel and implemented via the Olson database in userspace. So it's pointless to request that this second struct is to be populated, and everyone passes the null pointer for that argument which means "don't bother." The POSIX spec even goes so far as to state that if you *don't* pass the null pointer for the second argument, the behavior is unspecified, which is a clear signal that no code should ever be trying to get timezone information from this API. Okay, so PHP provides [`gettimeofday()`](http://www.php.net/manual/en/function.gettimeofday.php) that faithfully mirrors that interface and returns an associative array containing the four fields of both structs. Naturally, it didn't get the memo that the timezone information is completely useless and obsolete, nor do they even bother to document it. But at least it returns the two integers unmolested. You could use this, but it takes a little work. Then some bright bulb must have noticed that it was a little awkward to use `gettimeofday()`, so they wrote `microtime()`, which apparently just calls `gettimeofday()` and rearranges the two returned integers into a format that is unequivocally useless. How does that make anything better? In version 5.0.0 an optional boolean parameter was added to `microtime()` to specify the desire for a floating point return value, and then in 5.1.0 (!!) an optional boolean parameter was added to `gettimeofday()` to specify the same thing. Why are there two functions? Why did it take an entire major release to realize that having the information as a floating point value might be useful from both functions? Moreover, why is PHP's standard library so unwilling to do anything but offer trivial wrappers around existing C functions? Shouldn't a time and date library have some kind of cohesive design behind it? What do you do in PHP if you don't want wall-clock time but a monotonic clock source? (The `gettimeofday()` syscall is deprecated in favor of `clock_gettime()` which has multiple time sources for this reason.) What do you do if you're running on a platform that isn't POSIX and doesn't have any such `gettimeofday()` syscall? Let's talk about that for a minute. The documentation for `microtime()` says: > This function is only available on operating systems that support the gettimeofday() system call. The documentation for `gettimeofday()` says: > This is an interface to gettimeofday(2). Let's put aside for a minute the inherent inconsistency in this wording: surely if one is available then both should be available. But `gettimeofday()` doesn't actually say what systems it's available on. Presumably any system without such a syscall cannot use these functions, right? Nope. There's a compatibility shim for Windows where there is no such syscall. So not only is this API designed around a particular platform-specific API, and not only does the documentation imply that it will only work on such platforms, but in fact it will work on systems without that syscall. Or at least Windows. If you run PHP on a non-POSIX non-Windows system, then you're screwed. In summary: Who in the hell is responsible for this horrible mess??!? <|eor|><|sor|>> Who in the hell is responsible for this horrible mess??!? You said the key word: "responsible". I don't think in PHP anybody is responsible, for anything. Nowhere the age-old declaration about the software is more fitting than here: "no warranty of suitability for any particular purpose". If PHP does what you want: good for you. If it doesn't: tough luck. <|eor|><|sor|>> If PHP does what you want: good for you. If it does what you want, it's probably a good indication that you haven't thought of your problem-space enough.<|eor|><|eols|><|endoftext|>
8
lolphp
siroki
chf9w8b
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>"Unequivocally useless" is a bit harsh. You can calculate what you need to know from the return value of microtime(), string version. You just have to do a littttle bit more work that's all. eg: [https://eval.in/149569]<|eor|><|soopr|>Yes, and you can implement it perfectly every time. Or make a wrapper function, that provides a sane result. Or maybe you could've made the original function like that wrapper. Just like any sane API designer would.<|eoopr|><|eols|><|endoftext|>
7
lolphp
bart2019
chd13fe
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>someone doesn't understand floating point precision and how mantissas work<|eor|><|sor|>Yeah. Except floating point in PHP is "double", meaning you have 53 bits of mantissa in a float: plenty for fitting in 32 bits for Unix epoch time and 20 bits for the fractional part in millionths of a second.<|eor|><|eols|><|endoftext|>
6
lolphp
Rhomboid
chd2j45
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>Dat string return value. Lolphp Gold. Why would anyone ever favour returning "0.1234 567" instead of 567.1234?<|eor|><|sor|>Well, because you can't exactly represent every microsecond as a unique float. You'll run into float rounding and get big blocks of consecutive microseconds that are equal to each other. You also can't just return a number of microseconds since the epoch because it can overflow an integer. The underlying C function returns a struct with an integer of seconds and an integer of microseconds within that second. Most other languages either return a `Time` object of some sort that internally uses the same two integer representation or return a microsecond timestamp as an arbitrary precision number. PHP, though, didn't have objects at the time this function was created. They still don't have a primitive arbitrary precision type. I can't remember where off the top of my head (and I don't care enough to go look it up) but I do know they use strings to represent arbitrary precision numbers at a few other places in the standard library. In general, that's probably the least bad way around the problem, but I'm not sure why they didn't just return a two-element array in this case.<|eor|><|sor|>> you can't exactly represent every microsecond as a unique float An IEEE double can represent very close to 16 decimal digits worth of precision -- 53*log10(2) &asymp; 15.955 digits to be exact. An epoch with microsecond accuracy is 10 + 6 = 16 decimal digits. So it's extremely close to being able to represent any microsecond value. You might be off by one ULP once in a blue moon. <|eor|><|eols|><|endoftext|>
6
lolphp
_vec_
chd1pl6
<|sols|><|sot|>microtime: stupid specification, terrible documentation, optional fix came at a later version<|eot|><|sol|>http://www.php.net/manual/en/function.microtime.php<|eol|><|sor|>Dat string return value. Lolphp Gold. Why would anyone ever favour returning "0.1234 567" instead of 567.1234?<|eor|><|sor|>Well, because you can't exactly represent every microsecond as a unique float. You'll run into float rounding and get big blocks of consecutive microseconds that are equal to each other. You also can't just return a number of microseconds since the epoch because it can overflow an integer. The underlying C function returns a struct with an integer of seconds and an integer of microseconds within that second. Most other languages either return a `Time` object of some sort that internally uses the same two integer representation or return a microsecond timestamp as an arbitrary precision number. PHP, though, didn't have objects at the time this function was created. They still don't have a primitive arbitrary precision type. I can't remember where off the top of my head (and I don't care enough to go look it up) but I do know they use strings to represent arbitrary precision numbers at a few other places in the standard library. In general, that's probably the least bad way around the problem, but I'm not sure why they didn't just return a two-element array in this case.<|eor|><|eols|><|endoftext|>
5
lolphp
n1c0_ds
20x95z
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|eols|><|endoftext|>
30
lolphp
tdammers
cg7n1cs
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|eols|><|endoftext|>
15
lolphp
tdammers
cg7rbwp
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|soopr|>>Values from numeric columns (INT, FLOAT, ...) are returned as strings And parameterized queries pass everything as strings. I also discovered that bindParam doesn't even validate that the parameter has the correct type. You can pass bind an array value to an int parameter and PHP will silently convert it however it wants. One more: * PDO doesn't really work with SQL Server, but they have discontinued mssql_* functions anyway, because fuck you.<|eoopr|><|sor|>PHP with SQL Server? What are you, some sort of BDSM nutjob?<|eor|><|eols|><|endoftext|>
13
lolphp
n1c0_ds
cg7o35g
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|soopr|>>Values from numeric columns (INT, FLOAT, ...) are returned as strings And parameterized queries pass everything as strings. I also discovered that bindParam doesn't even validate that the parameter has the correct type. You can pass bind an array value to an int parameter and PHP will silently convert it however it wants. One more: * PDO doesn't really work with SQL Server, but they have discontinued mssql_* functions anyway, because fuck you.<|eoopr|><|eols|><|endoftext|>
11
lolphp
ajmarks
cg7ot00
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|sor|>> (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway". That's just painful. <|eor|><|eols|><|endoftext|>
10
lolphp
tdammers
cg7ra4p
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|sor|>Returning numbers as strings drove me absolutely bonkers one night. I was convinced it was my code (which wasn't complex), because PHP can't be *that* dumb. It is. Apparently, it has something to do with how the C extension handles talking to the database and limits on how big a number or float can be in C. I don't want to say it sounds like a failure on the PHP devs' fault because I don't know C. But when every other language can seem to handle or deal with this in some way...it sounds like it's their fault.<|eor|><|sor|>The real reason is because PHP has no reliable exact numeric type. None. It has integers, but they are subject to float promotion at the runtime's discretion (and the cutoff point depends on the machine word size of the underlying platform), so the only round-trip-safe way of returning numeric values from a database in PHP is, unfortunately, using strings.<|eor|><|eols|><|endoftext|>
7
lolphp
catcradle5
cg7t8t5
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|sor|>> PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. I was actually unaware of this until a while back. In a penetration test, I saw a PDO error message with the credentials right in the 1-line error, which of course let me pivot very easily. I would bet that this one "feature" has resulted in numerous application compromises over the years. Sometimes a dev forgets to set error_reporting to 0, or sometimes they leave up a test/debugging script in a forgotten directory which otherwise has no flaws but is unable to connect to the DB and then magically spits out the DB user and password.<|eor|><|eols|><|endoftext|>
6
lolphp
TJ09
cg7r7f9
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|sor|>Returning numbers as strings drove me absolutely bonkers one night. I was convinced it was my code (which wasn't complex), because PHP can't be *that* dumb. It is. Apparently, it has something to do with how the C extension handles talking to the database and limits on how big a number or float can be in C. I don't want to say it sounds like a failure on the PHP devs' fault because I don't know C. But when every other language can seem to handle or deal with this in some way...it sounds like it's their fault.<|eor|><|sor|>IIRC, if you set the option PDO::ATTR_EMULATE_PREPARES to false, you get normal returns types (when talking to MySQL, anyways). I'm not quite sure I want to know why an option that should have no effect on MySQL (which supports prepared queries) has that effect.<|eor|><|eols|><|endoftext|>
6
lolphp
n1c0_ds
cg7rfec
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|soopr|>>Values from numeric columns (INT, FLOAT, ...) are returned as strings And parameterized queries pass everything as strings. I also discovered that bindParam doesn't even validate that the parameter has the correct type. You can pass bind an array value to an int parameter and PHP will silently convert it however it wants. One more: * PDO doesn't really work with SQL Server, but they have discontinued mssql_* functions anyway, because fuck you.<|eoopr|><|sor|>PHP with SQL Server? What are you, some sort of BDSM nutjob?<|eor|><|soopr|>I wish it was the worst part<|eoopr|><|eols|><|endoftext|>
6
lolphp
skillet-thief
cg7rof8
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|sor|>Returning numbers as strings drove me absolutely bonkers one night. I was convinced it was my code (which wasn't complex), because PHP can't be *that* dumb. It is. Apparently, it has something to do with how the C extension handles talking to the database and limits on how big a number or float can be in C. I don't want to say it sounds like a failure on the PHP devs' fault because I don't know C. But when every other language can seem to handle or deal with this in some way...it sounds like it's their fault.<|eor|><|sor|>The real reason is because PHP has no reliable exact numeric type. None. It has integers, but they are subject to float promotion at the runtime's discretion (and the cutoff point depends on the machine word size of the underlying platform), so the only round-trip-safe way of returning numeric values from a database in PHP is, unfortunately, using strings.<|eor|><|sor|>This was with mysqli, a few years back, but I had to switch from postgres to mysql at one point, and had all kinds of new bugs because what had come back as integers was now coming back as strings. <|eor|><|eols|><|endoftext|>
5
lolphp
tdammers
cg9oljg
<|sols|><|sot|>PDO conveniently convert nulls to 0<|eot|><|sol|>https://bugs.php.net/bug.php?id=44835<|eol|><|sor|>Other related fuck-ups: * Values from numeric columns (INT, FLOAT, ...) are returned as *strings* * Data to and from the database is generally assumed to be raw bytestrings; making sure the PHP side and the database use the same encoding is the responsibility of the programmer. * (This one's my favorite:) PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. According to the PHP folks, this is "by design" and "not a problem", because "you're not supposed to expose error messages anyway".<|eor|><|sor|>> PDO sometimes includes the database credentials, including the password, in the error message. Depending on how the system is configured, the password can thus leak to log files, the response body, and who knows where else. I was actually unaware of this until a while back. In a penetration test, I saw a PDO error message with the credentials right in the 1-line error, which of course let me pivot very easily. I would bet that this one "feature" has resulted in numerous application compromises over the years. Sometimes a dev forgets to set error_reporting to 0, or sometimes they leave up a test/debugging script in a forgotten directory which otherwise has no flaws but is unable to connect to the DB and then magically spits out the DB user and password.<|eor|><|sor|>Indeed. Worse yet, you can't really reliably work around this flaw other than disabling error logging and error outputting altogether. Which is bad, because if at some point an error makes it to the top, I do want to know - an error log is a very useful tool, *especially* in a production setting, but I absolutely cannot have database credentials in the logfile. Through this policy, the PHP folks have essentially made error logging on production server a no-go area.<|eor|><|sor|>Unless you can provide some specific examples, I call BS on this. With a sensible error handler and exception handler, it's relatively trivial to have all uncaught errors / exceptions logged and never display them to the visitor. Add in a shutdown handler and a cron job and you can even have most fatal error cases dealt with by code to atleast some degree.<|eor|><|sor|>Logging passwords is almost as bad as displaying them to visitors, security wise, if only because a logfile with passwords in it unnecessarily increases attack surface, more so if you throw in common logfile strategies such as automatically mailing logs around, log rotating, backing up logfiles, analytics, etc. Just too many things touching and exposing your logfiles to who knows what and who - impossible to protect this in a "100% sure we know all the risks" way. Logging SQL errors, however, is absolutely desirable - if your code produces those, you really really want to know. So what are the choices? Sacrifice some security (log errors anyway and risk passwords in log files)? Set up custom error handling, at the risk of having passwords logged anyway, and also missing important information? Not log anything, and accept that things can blow up without you noticing? Meticulously audit all your code to make sure anything that can throw a PDOException is wrapped in a suitable ad-hoc exception handler that makes sure they can't get through? None of these sound very tempting.<|eor|><|eols|><|endoftext|>
5
lolphp
jamwaffles
1ih52d
<|sols|><|sot|>Casting an object to an array yields binary keys that look like strings<|eot|><|sol|>http://stackoverflow.com/questions/17695490/php-cast-object-to-array-strange-behaviour<|eol|><|eols|><|endoftext|>
28
lolphp
steamruler
cb4f58e
<|sols|><|sot|>Casting an object to an array yields binary keys that look like strings<|eot|><|sol|>http://stackoverflow.com/questions/17695490/php-cast-object-to-array-strange-behaviour<|eol|><|sor|>Looks like they're trying to get private variables from an object. There's a reason you can't do that easily.<|eor|><|sor|>But you can still do it. That could probably also classify as a lolphp.<|eor|><|eols|><|endoftext|>
10
lolphp
PhantomRacer
cb4eis5
<|sols|><|sot|>Casting an object to an array yields binary keys that look like strings<|eot|><|sol|>http://stackoverflow.com/questions/17695490/php-cast-object-to-array-strange-behaviour<|eol|><|sor|>Looks like they're trying to get private variables from an object. There's a reason you can't do that easily.<|eor|><|eols|><|endoftext|>
9
lolphp
Fitzsimmons
cb4hgp6
<|sols|><|sot|>Casting an object to an array yields binary keys that look like strings<|eot|><|sol|>http://stackoverflow.com/questions/17695490/php-cast-object-to-array-strange-behaviour<|eol|><|sor|>Looks like they're trying to get private variables from an object. There's a reason you can't do that easily.<|eor|><|sor|>But you can still do it. That could probably also classify as a lolphp.<|eor|><|sor|>Getting privates out of an object is possible in every language I've used, with varying levels of difficulty. I'd have to say this is one of the few cases that isn't a lolphp on its own. The interface being used is pretty abysmal but it might not be the best way. <|eor|><|eols|><|endoftext|>
8
lolphp
nikic
cb55xaq
<|sols|><|sot|>Casting an object to an array yields binary keys that look like strings<|eot|><|sol|>http://stackoverflow.com/questions/17695490/php-cast-object-to-array-strange-behaviour<|eol|><|sor|>What you see here is called "property name mangling". You can find an explanation for why this is internally necessary here: http://www.phpinternalsbook.com/classes_objects/internal_structures_and_implementation.html#property-name-mangling The object to array cast should be the only place where this implementation detail is leaked to userland. It's something I personally would like to remove (and only return the public properties), but some projects require fast access to private properties and misuse this "bug" to do so (most notably ORMs need this).<|eor|><|eols|><|endoftext|>
7
lolphp
nikic
1choxy
<|sols|><|sot|>PHP's comparison operators are weird...<|eot|><|sol|>http://stackoverflow.com/q/15813490/385378<|eol|><|eols|><|endoftext|>
28
lolphp
subWoofer_0870
m8ud8s
<|sols|><|sot|>Time zones r us<|eot|><|sol|>/r/talesfromtechsupport/comments/m8ep6m/the_clocks_wrong/<|eol|><|eols|><|endoftext|>
27
lolphp
Takeoded
hy5rsv
<|soss|><|sot|>file_put_contents() supports LOCK_EX, but file_get_contents() does not support LOCK_SH<|eot|><|sost|><|eost|><|eoss|><|endoftext|>
26
lolphp
pilif
fzamgs0
<|soss|><|sot|>file_put_contents() supports LOCK_EX, but file_get_contents() does not support LOCK_SH<|eot|><|sost|><|eost|><|sor|>The real WTF is the note in the manual about the use_include_path parameter and strict typing<|eor|><|eoss|><|endoftext|>
17
lolphp
Takeoded
fzascgd
<|soss|><|sot|>file_put_contents() supports LOCK_EX, but file_get_contents() does not support LOCK_SH<|eot|><|sost|><|eost|><|sor|>The real WTF is the note in the manual about the use_include_path parameter and strict typing<|eor|><|soopr|>speaking of, bool $use_include_path should be changed to int $flags anyway, then it could take both FILE_USE_INCLUDE_PATH *and* LOCK_SH as flags<|eoopr|><|eoss|><|endoftext|>
6
lolphp
SeriTools
fzb6u1s
<|soss|><|sot|>file_put_contents() supports LOCK_EX, but file_get_contents() does not support LOCK_SH<|eot|><|sost|><|eost|><|sor|>The real WTF is the note in the manual about the use_include_path parameter and strict typing<|eor|><|soopr|>speaking of, bool $use_include_path should be changed to int $flags anyway, then it could take both FILE_USE_INCLUDE_PATH *and* LOCK_SH as flags<|eoopr|><|sor|>That's probably problematic since existing code may pass in some int already that is getting converted to bool, which may change the behavior.<|eor|><|eoss|><|endoftext|>
5
lolphp
fotcorn
b0ondc
<|sols|><|sot|>Let's make the first parameter optional completely changing the meaning of argument names<|eot|><|sol|>https://i.redd.it/xbtn1recfwl21.png<|eol|><|eols|><|endoftext|>
26
lolphp
vita10gy
eig6pu1
<|sols|><|sot|>Let's make the first parameter optional completely changing the meaning of argument names<|eot|><|sol|>https://i.redd.it/xbtn1recfwl21.png<|eol|><|sor|>This isn't /r/loldevsdodumbthings<|eor|><|eols|><|endoftext|>
17
lolphp
dotancohen
eihtrt5
<|sols|><|sot|>Let's make the first parameter optional completely changing the meaning of argument names<|eot|><|sol|>https://i.redd.it/xbtn1recfwl21.png<|eol|><|sor|>Not sure if you've seen the pgSQL API but... yeah. http://php.net/manual/en/function.pg-query.php<|eor|><|sor|>The mods should replace the submission, which is not a PHPlol but a devs-were-drunk-lol, with this. Or with `implode()`, which can accept its parameters in either order.<|eor|><|eols|><|endoftext|>
10
lolphp
SaraMG
eih8ajj
<|sols|><|sot|>Let's make the first parameter optional completely changing the meaning of argument names<|eot|><|sol|>https://i.redd.it/xbtn1recfwl21.png<|eol|><|sor|>Not sure if you've seen the pgSQL API but... yeah. http://php.net/manual/en/function.pg-query.php<|eor|><|eols|><|endoftext|>
8
lolphp
ImNewHereBoys
eis0h1h
<|sols|><|sot|>Let's make the first parameter optional completely changing the meaning of argument names<|eot|><|sol|>https://i.redd.it/xbtn1recfwl21.png<|eol|><|sor|>This has nothing to do with php i guess except that the developer wrote it in php.<|eor|><|eols|><|endoftext|>
7
lolphp
fotcorn
eig05f6
<|sols|><|sot|>Let's make the first parameter optional completely changing the meaning of argument names<|eot|><|sol|>https://i.redd.it/xbtn1recfwl21.png<|eol|><|soopr|>At least the framework developers agree and deprecated the $code argument: https://github.com/nette/application/blob/master/src/Application/UI/Component.php#L285<|eoopr|><|eols|><|endoftext|>
5
lolphp
Perdouille
eigloyp
<|sols|><|sot|>Let's make the first parameter optional completely changing the meaning of argument names<|eot|><|sol|>https://i.redd.it/xbtn1recfwl21.png<|eol|><|sor|>How is this different from overloading from the callers perspective?<|eor|><|sor|>Your IDE will show you the function arguments as $code, $destination and $args, but $code will be $destination and $destination will be $args, which will be confusing<|eor|><|eols|><|endoftext|>
5
lolphp
shaql
9un2lo
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|eols|><|endoftext|>
28
lolphp
DCoder1337
e95hvj1
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|soopr|>Can someone please explain to me, just, *why*? (Preferably ELI5, I don't really know what is TSRM, Zend, etc., or what this code is supposed to do :P) I also found https://bugs.php.net/bug.php?id=52312 , which is way too long and I'm too lazy to read it all, but it contains: > I have defined into TSRM/tsrm_virtual_cwd.c > > #define realpath(x,y) strcpy(y,x) > > and I have disabled PHP function symlink. > > Now I finally not have performance problems, but I suppose I still can have > security problem. And this: https://download.pureftpd.org/misc/php-5.2.0-norealpath.patch, with a truly lolphpy `REALLY_USE_REALPATH` D:<|eoopr|><|sor|>*nix systems have a native `realpath()` function that does basically the same thing as PHP's `realpath()` it normalizes the given path and resolves any symlinks. But when the system that PHP is running on does not have a native `realpath()` function (e.g. running on Win32 or exotic BS like BeOS), PHP needs some alternate implementation. So it goes `\_()_/` and implements a "just return whatever was passed in" solution. The patch you refer to looks like a double-edged sword. It's a security measure to safeguard against extremely long paths that could lead to buffer overflows. But if you blindly apply it without changing your build steps to add `REALLY_USE_REALPATH`, it will stop using the native `realpath()` functionality even if it is available. --- A buffer overflow is a classic security problem, the details of which are not relevant to appreciate this lolphp.<|eor|><|eols|><|endoftext|>
17
lolphp
shaql
e95g5ac
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|soopr|>Can someone please explain to me, just, *why*? (Preferably ELI5, I don't really know what is TSRM, Zend, etc., or what this code is supposed to do :P) I also found https://bugs.php.net/bug.php?id=52312 , which is way too long and I'm too lazy to read it all, but it contains: > I have defined into TSRM/tsrm_virtual_cwd.c > > #define realpath(x,y) strcpy(y,x) > > and I have disabled PHP function symlink. > > Now I finally not have performance problems, but I suppose I still can have > security problem. And this: https://download.pureftpd.org/misc/php-5.2.0-norealpath.patch, with a truly lolphpy `REALLY_USE_REALPATH` D:<|eoopr|><|eols|><|endoftext|>
11
lolphp
sproingie
e97g2wy
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|soopr|>Can someone please explain to me, just, *why*? (Preferably ELI5, I don't really know what is TSRM, Zend, etc., or what this code is supposed to do :P) I also found https://bugs.php.net/bug.php?id=52312 , which is way too long and I'm too lazy to read it all, but it contains: > I have defined into TSRM/tsrm_virtual_cwd.c > > #define realpath(x,y) strcpy(y,x) > > and I have disabled PHP function symlink. > > Now I finally not have performance problems, but I suppose I still can have > security problem. And this: https://download.pureftpd.org/misc/php-5.2.0-norealpath.patch, with a truly lolphpy `REALLY_USE_REALPATH` D:<|eoopr|><|sor|>*nix systems have a native `realpath()` function that does basically the same thing as PHP's `realpath()` it normalizes the given path and resolves any symlinks. But when the system that PHP is running on does not have a native `realpath()` function (e.g. running on Win32 or exotic BS like BeOS), PHP needs some alternate implementation. So it goes `\_()_/` and implements a "just return whatever was passed in" solution. The patch you refer to looks like a double-edged sword. It's a security measure to safeguard against extremely long paths that could lead to buffer overflows. But if you blindly apply it without changing your build steps to add `REALLY_USE_REALPATH`, it will stop using the native `realpath()` functionality even if it is available. --- A buffer overflow is a classic security problem, the details of which are not relevant to appreciate this lolphp.<|eor|><|soopr|>I understand all that (and buffer overflows), it's the "just return whatever was passed in" part that baffles me. Considering C's realpath() is supposed to safeguard against symlinks, dir traversals, etc, not using realpath() would be much safer than using this strcpy() version (with added buffer overflows, and a null pointer dereference (realpath() is supposed to handle the second param being NULL)). I don't see any usage of this redefined realpath() in that .c file, so I have no clue how a malicious actor can exploit it, but still... *why*?! That file defines two similar functions, virtual_realpath() and tsrm_realpath() (I might look into how they work later), so why is that define there? <|eoopr|><|sor|>I agree with this, really calling realpath if it isn't defined legitimately (eg in the native POSIX system or with a platform dependent replacement) should (ultimately) throw an exception (however that's done in C). People call it specifically to check the security of a link. If it is incapable of doing that, it should ensure the code that called it fails, not fake a success. &#x200B;<|eor|><|sor|>It's the PHP design ethos: if it can't be done, just make some shit up, muddle along with it, and silently cover up how broken it is.<|eor|><|eols|><|endoftext|>
11
lolphp
DCoder1337
e95jxh8
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|soopr|>Can someone please explain to me, just, *why*? (Preferably ELI5, I don't really know what is TSRM, Zend, etc., or what this code is supposed to do :P) I also found https://bugs.php.net/bug.php?id=52312 , which is way too long and I'm too lazy to read it all, but it contains: > I have defined into TSRM/tsrm_virtual_cwd.c > > #define realpath(x,y) strcpy(y,x) > > and I have disabled PHP function symlink. > > Now I finally not have performance problems, but I suppose I still can have > security problem. And this: https://download.pureftpd.org/misc/php-5.2.0-norealpath.patch, with a truly lolphpy `REALLY_USE_REALPATH` D:<|eoopr|><|sor|>*nix systems have a native `realpath()` function that does basically the same thing as PHP's `realpath()` it normalizes the given path and resolves any symlinks. But when the system that PHP is running on does not have a native `realpath()` function (e.g. running on Win32 or exotic BS like BeOS), PHP needs some alternate implementation. So it goes `\_()_/` and implements a "just return whatever was passed in" solution. The patch you refer to looks like a double-edged sword. It's a security measure to safeguard against extremely long paths that could lead to buffer overflows. But if you blindly apply it without changing your build steps to add `REALLY_USE_REALPATH`, it will stop using the native `realpath()` functionality even if it is available. --- A buffer overflow is a classic security problem, the details of which are not relevant to appreciate this lolphp.<|eor|><|soopr|>I understand all that (and buffer overflows), it's the "just return whatever was passed in" part that baffles me. Considering C's realpath() is supposed to safeguard against symlinks, dir traversals, etc, not using realpath() would be much safer than using this strcpy() version (with added buffer overflows, and a null pointer dereference (realpath() is supposed to handle the second param being NULL)). I don't see any usage of this redefined realpath() in that .c file, so I have no clue how a malicious actor can exploit it, but still... *why*?! That file defines two similar functions, virtual_realpath() and tsrm_realpath() (I might look into how they work later), so why is that define there? <|eoopr|><|sor|>`realpath` is not part of C standard library, it originates from POSIX. PHP can't use it if the operating system does not provide it. Like I wrote, the best example of such an operating system is Windows. A less-common example is the defunct BeOS. Gnulib documents this point: https://www.gnu.org/software/gnulib/manual/html_node/realpath.html<|eor|><|eols|><|endoftext|>
9
lolphp
barubary
e9666qt
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|soopr|>Can someone please explain to me, just, *why*? (Preferably ELI5, I don't really know what is TSRM, Zend, etc., or what this code is supposed to do :P) I also found https://bugs.php.net/bug.php?id=52312 , which is way too long and I'm too lazy to read it all, but it contains: > I have defined into TSRM/tsrm_virtual_cwd.c > > #define realpath(x,y) strcpy(y,x) > > and I have disabled PHP function symlink. > > Now I finally not have performance problems, but I suppose I still can have > security problem. And this: https://download.pureftpd.org/misc/php-5.2.0-norealpath.patch, with a truly lolphpy `REALLY_USE_REALPATH` D:<|eoopr|><|sor|>*nix systems have a native `realpath()` function that does basically the same thing as PHP's `realpath()` it normalizes the given path and resolves any symlinks. But when the system that PHP is running on does not have a native `realpath()` function (e.g. running on Win32 or exotic BS like BeOS), PHP needs some alternate implementation. So it goes `\_()_/` and implements a "just return whatever was passed in" solution. The patch you refer to looks like a double-edged sword. It's a security measure to safeguard against extremely long paths that could lead to buffer overflows. But if you blindly apply it without changing your build steps to add `REALLY_USE_REALPATH`, it will stop using the native `realpath()` functionality even if it is available. --- A buffer overflow is a classic security problem, the details of which are not relevant to appreciate this lolphp.<|eor|><|soopr|>I understand all that (and buffer overflows), it's the "just return whatever was passed in" part that baffles me. Considering C's realpath() is supposed to safeguard against symlinks, dir traversals, etc, not using realpath() would be much safer than using this strcpy() version (with added buffer overflows, and a null pointer dereference (realpath() is supposed to handle the second param being NULL)). I don't see any usage of this redefined realpath() in that .c file, so I have no clue how a malicious actor can exploit it, but still... *why*?! That file defines two similar functions, virtual_realpath() and tsrm_realpath() (I might look into how they work later), so why is that define there? <|eoopr|><|sor|>I agree with this, really calling realpath if it isn't defined legitimately (eg in the native POSIX system or with a platform dependent replacement) should (ultimately) throw an exception (however that's done in C). People call it specifically to check the security of a link. If it is incapable of doing that, it should ensure the code that called it fails, not fake a success. &#x200B;<|eor|><|sor|>> throw an exception (however that's done in C). I guess you'd do this: static char *realpath(const char *in, char *out) { (void)in; (void)out; errno = ENOSYS; return NULL; } I.e. silence compiler warnings about unused parameters, return a null pointer to indicate failure, and set `errno` to `ENOSYS` ("Function not implemented").<|eor|><|eols|><|endoftext|>
8
lolphp
shaql
e95j91o
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|soopr|>Can someone please explain to me, just, *why*? (Preferably ELI5, I don't really know what is TSRM, Zend, etc., or what this code is supposed to do :P) I also found https://bugs.php.net/bug.php?id=52312 , which is way too long and I'm too lazy to read it all, but it contains: > I have defined into TSRM/tsrm_virtual_cwd.c > > #define realpath(x,y) strcpy(y,x) > > and I have disabled PHP function symlink. > > Now I finally not have performance problems, but I suppose I still can have > security problem. And this: https://download.pureftpd.org/misc/php-5.2.0-norealpath.patch, with a truly lolphpy `REALLY_USE_REALPATH` D:<|eoopr|><|sor|>*nix systems have a native `realpath()` function that does basically the same thing as PHP's `realpath()` it normalizes the given path and resolves any symlinks. But when the system that PHP is running on does not have a native `realpath()` function (e.g. running on Win32 or exotic BS like BeOS), PHP needs some alternate implementation. So it goes `\_()_/` and implements a "just return whatever was passed in" solution. The patch you refer to looks like a double-edged sword. It's a security measure to safeguard against extremely long paths that could lead to buffer overflows. But if you blindly apply it without changing your build steps to add `REALLY_USE_REALPATH`, it will stop using the native `realpath()` functionality even if it is available. --- A buffer overflow is a classic security problem, the details of which are not relevant to appreciate this lolphp.<|eor|><|soopr|>I understand all that (and buffer overflows), it's the "just return whatever was passed in" part that baffles me. Considering C's realpath() is supposed to safeguard against symlinks, dir traversals, etc, not using realpath() would be much safer than using this strcpy() version (with added buffer overflows, and a null pointer dereference (realpath() is supposed to handle the second param being NULL)). I don't see any usage of this redefined realpath() in that .c file, so I have no clue how a malicious actor can exploit it, but still... *why*?! That file defines two similar functions, virtual_realpath() and tsrm_realpath() (I might look into how they work later), so why is that define there? <|eoopr|><|eols|><|endoftext|>
7
lolphp
AyrA_ch
e95vynp
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|soopr|>Can someone please explain to me, just, *why*? (Preferably ELI5, I don't really know what is TSRM, Zend, etc., or what this code is supposed to do :P) I also found https://bugs.php.net/bug.php?id=52312 , which is way too long and I'm too lazy to read it all, but it contains: > I have defined into TSRM/tsrm_virtual_cwd.c > > #define realpath(x,y) strcpy(y,x) > > and I have disabled PHP function symlink. > > Now I finally not have performance problems, but I suppose I still can have > security problem. And this: https://download.pureftpd.org/misc/php-5.2.0-norealpath.patch, with a truly lolphpy `REALLY_USE_REALPATH` D:<|eoopr|><|sor|>*nix systems have a native `realpath()` function that does basically the same thing as PHP's `realpath()` it normalizes the given path and resolves any symlinks. But when the system that PHP is running on does not have a native `realpath()` function (e.g. running on Win32 or exotic BS like BeOS), PHP needs some alternate implementation. So it goes `\_()_/` and implements a "just return whatever was passed in" solution. The patch you refer to looks like a double-edged sword. It's a security measure to safeguard against extremely long paths that could lead to buffer overflows. But if you blindly apply it without changing your build steps to add `REALLY_USE_REALPATH`, it will stop using the native `realpath()` functionality even if it is available. --- A buffer overflow is a classic security problem, the details of which are not relevant to appreciate this lolphp.<|eor|><|soopr|>I understand all that (and buffer overflows), it's the "just return whatever was passed in" part that baffles me. Considering C's realpath() is supposed to safeguard against symlinks, dir traversals, etc, not using realpath() would be much safer than using this strcpy() version (with added buffer overflows, and a null pointer dereference (realpath() is supposed to handle the second param being NULL)). I don't see any usage of this redefined realpath() in that .c file, so I have no clue how a malicious actor can exploit it, but still... *why*?! That file defines two similar functions, virtual_realpath() and tsrm_realpath() (I might look into how they work later), so why is that define there? <|eoopr|><|sor|>`realpath` is not part of C standard library, it originates from POSIX. PHP can't use it if the operating system does not provide it. Like I wrote, the best example of such an operating system is Windows. A less-common example is the defunct BeOS. Gnulib documents this point: https://www.gnu.org/software/gnulib/manual/html_node/realpath.html<|eor|><|sor|>> Like I wrote, the best example of such an operating system is Windows. [Excuse Me](https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfullpathnamew)<|eor|><|eols|><|endoftext|>
7
lolphp
shaql
e97qci2
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|soopr|>Ok, I did some more research... That file I linked to was previously known as TSRM/tsrm_virtual_cwd.c The weird define was added in [this patch](https://git.php.net/?p=php-src.git;a=commitdiff;h=2a0fbded3dc3f366cf3e4bfd3a42c7a2f5d2b745), to support BeOS, and the ifdef was changed in [that patch](https://git.php.net/?p=php-src.git;a=commitdiff;h=78e2e69b23a6811f148f68fcabe41dedc9e29005), to resolve [a bug](https://bugs.php.net/bug.php?id=18868). As you can see in [that old code](https://git.php.net/?p=php-src.git;a=blob;f=TSRM/tsrm_virtual_cwd.c;h=12c35e1ced2962e32c270a6c80d3fdeb525f4574;hb=78e2e69b23a6811f148f68fcabe41dedc9e29005#l307), `realpath()` was used a few times. These days, [as you can see](https://git.php.net/?p=php-src.git&a=search&h=HEAD&st=grep&s=realpath%28), `realpath()` isn't used, instead they're using their own implementation. [That](https://git.php.net/?p=php-src.git;a=blob;f=sapi/litespeed/lsapilib.c;hb=8c7aa88e2d2ae519160cad7acf220c09ca17f18e#l3524) seems to be the only usage of the 'old' `realpath()`, which may end up being `strcpy()`, or [that](https://git.php.net/?p=php-src.git;a=blob;f=win32/ioutil.c;hb=8c7aa88e2d2ae519160cad7acf220c09ca17f18e#l785), who knows :P So in short, that whole `strcpy()` define is an old thing that should no longer be a thing (and never should have been a thing, for that matter).<|eoopr|><|eols|><|endoftext|>
6
lolphp
shaql
e98qh14
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|sor|>What's up with those `do { x } while(0);`?<|eor|><|soopr|>https://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for ;]<|eoopr|><|eols|><|endoftext|>
6
lolphp
squiggleslash
e95wtu2
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|soopr|>Can someone please explain to me, just, *why*? (Preferably ELI5, I don't really know what is TSRM, Zend, etc., or what this code is supposed to do :P) I also found https://bugs.php.net/bug.php?id=52312 , which is way too long and I'm too lazy to read it all, but it contains: > I have defined into TSRM/tsrm_virtual_cwd.c > > #define realpath(x,y) strcpy(y,x) > > and I have disabled PHP function symlink. > > Now I finally not have performance problems, but I suppose I still can have > security problem. And this: https://download.pureftpd.org/misc/php-5.2.0-norealpath.patch, with a truly lolphpy `REALLY_USE_REALPATH` D:<|eoopr|><|sor|>*nix systems have a native `realpath()` function that does basically the same thing as PHP's `realpath()` it normalizes the given path and resolves any symlinks. But when the system that PHP is running on does not have a native `realpath()` function (e.g. running on Win32 or exotic BS like BeOS), PHP needs some alternate implementation. So it goes `\_()_/` and implements a "just return whatever was passed in" solution. The patch you refer to looks like a double-edged sword. It's a security measure to safeguard against extremely long paths that could lead to buffer overflows. But if you blindly apply it without changing your build steps to add `REALLY_USE_REALPATH`, it will stop using the native `realpath()` functionality even if it is available. --- A buffer overflow is a classic security problem, the details of which are not relevant to appreciate this lolphp.<|eor|><|soopr|>I understand all that (and buffer overflows), it's the "just return whatever was passed in" part that baffles me. Considering C's realpath() is supposed to safeguard against symlinks, dir traversals, etc, not using realpath() would be much safer than using this strcpy() version (with added buffer overflows, and a null pointer dereference (realpath() is supposed to handle the second param being NULL)). I don't see any usage of this redefined realpath() in that .c file, so I have no clue how a malicious actor can exploit it, but still... *why*?! That file defines two similar functions, virtual_realpath() and tsrm_realpath() (I might look into how they work later), so why is that define there? <|eoopr|><|sor|>I agree with this, really calling realpath if it isn't defined legitimately (eg in the native POSIX system or with a platform dependent replacement) should (ultimately) throw an exception (however that's done in C). People call it specifically to check the security of a link. If it is incapable of doing that, it should ensure the code that called it fails, not fake a success. &#x200B;<|eor|><|eols|><|endoftext|>
6
lolphp
Takeoded
e9r8lpe
<|sols|><|sot|>#define realpath(x,y) strcpy(y,x)<|eot|><|sol|>https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70<|eol|><|sor|>What's up with those `do { x } while(0);`?<|eor|><|soopr|>https://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for ;]<|eoopr|><|sor|>surprisingly that SO post doesn't mention the other use of do{}while(false), it allows you to use break; instead of labels+goto, instead of (stuff); goto lbl; (stuff); lbl: you can do do{ (stuff); break; (stuff); }while(false);<|eor|><|eols|><|endoftext|>
5
lolphp
eth4n_
85bj7b
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|eoss|><|endoftext|>
26
lolphp
chateau86
dvw7mc1
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>[BobX? I remember the thedailywtf post from back in the day.](http://thedailywtf.com/articles/We-Use-BobX)<|eor|><|eoss|><|endoftext|>
54
lolphp
calligraphic-io
dvwxotn
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>Why is it a "horror story"? Some people just don't like PHP's inconsistent syntax. I usually write PHP code with a macro preprocessor like [ccpp](https://github.com/metala/ccpp) and a build step. I use Ant to pull in a definition file for the preprocessor that replaces PHP's horrid syntax with something reasonable, like so: #define SWITCH switch( #define IN ){ #define ENDSW } #define FOR for( #define WHILE while( #define DO ){ #define ANDF && ... The resulting PHP DSL is clearly more consistent, and onboarding new devs is easy if they have some experience with ALGOL-family languages: <?php BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT PUNCH(3),??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),SAMELINE,ALIGNED(1,6),A,B,C' END' END' ?><|eor|><|sor|>To all the people down-voting our company's PHP DSL example, I'm putting you on a list for our hiring manager!<|eor|><|sor|>Positively or negatively? Real question - if your answer is "negatively" please go to the bar, have a couple drinks, quit your terrible job and maybe see a therapist. <|eor|><|sor|>The posts were meant as a joke, but I think my sense of humour is too dry for /r/lolphp (the **lol** in the subreddit name seems to be a misnomer). [Stephen Bourne](https://en.wikipedia.org/wiki/Stephen_R._Bourne) wrote the original shell utility for System V Unix while he worked at Bell Labs in the early '70s. He preferred Pascal to C, so he rewrote the C language via `#defines` to allow him to write the shell in ALGOL syntax. If you spend time digging through the source of commercial Unixes or \*BSDs (which is a common rite-of-passage in those OSs as the kernel and `world` are generally compiled from source, and the Bourne Shell is the standard shell vs. BASH in Linux-land), you'll eventually come across the `/bin/sh` source and have a first reaction of wtf?!? It *looks* like C, but it isn't! I've done what I described before with PHP as a joke entry in coding contests. I thought the joke on-topic to OPs question about PHP DSLs. The follow-up comment was a joke about all of the "industry leaders" who end up twittering that they'll never hire a whole group of people at their companies for X-Y-Z comments the people made on Twitter. It's happened enough times to at least be a solid meme on 4chan at this point. Anyways, I'm a nerd. I never could tell a joke, and either (a) /r/lolphp/lacks/lulz, or more likely (b) I still can't tell a joke.<|eor|><|eoss|><|endoftext|>
27
lolphp
calligraphic-io
dvwctxn
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>Why is it a "horror story"? Some people just don't like PHP's inconsistent syntax. I usually write PHP code with a macro preprocessor like [ccpp](https://github.com/metala/ccpp) and a build step. I use Ant to pull in a definition file for the preprocessor that replaces PHP's horrid syntax with something reasonable, like so: #define SWITCH switch( #define IN ){ #define ENDSW } #define FOR for( #define WHILE while( #define DO ){ #define ANDF && ... The resulting PHP DSL is clearly more consistent, and onboarding new devs is easy if they have some experience with ALGOL-family languages: <?php BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT PUNCH(3),??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),SAMELINE,ALIGNED(1,6),A,B,C' END' END' ?><|eor|><|eoss|><|endoftext|>
20
lolphp
calligraphic-io
dvwh4as
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>Why is it a "horror story"? Some people just don't like PHP's inconsistent syntax. I usually write PHP code with a macro preprocessor like [ccpp](https://github.com/metala/ccpp) and a build step. I use Ant to pull in a definition file for the preprocessor that replaces PHP's horrid syntax with something reasonable, like so: #define SWITCH switch( #define IN ){ #define ENDSW } #define FOR for( #define WHILE while( #define DO ){ #define ANDF && ... The resulting PHP DSL is clearly more consistent, and onboarding new devs is easy if they have some experience with ALGOL-family languages: <?php BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT PUNCH(3),??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),SAMELINE,ALIGNED(1,6),A,B,C' END' END' ?><|eor|><|sor|>To all the people down-voting our company's PHP DSL example, I'm putting you on a list for our hiring manager!<|eor|><|eoss|><|endoftext|>
17
lolphp
AyrA_ch
dvx1dic
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>[BobX? I remember the thedailywtf post from back in the day.](http://thedailywtf.com/articles/We-Use-BobX)<|eor|><|soopr|>aye thanks, that is what i was looking for +1<|eoopr|><|sor|>Not PHP but also worth mentioning: [JDSL or "the inner json effect"](http://thedailywtf.com/articles/the-inner-json-effect)<|eor|><|eoss|><|endoftext|>
17
lolphp
commitpushdrink
dvx0232
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>Why is it a "horror story"? Some people just don't like PHP's inconsistent syntax. I usually write PHP code with a macro preprocessor like [ccpp](https://github.com/metala/ccpp) and a build step. I use Ant to pull in a definition file for the preprocessor that replaces PHP's horrid syntax with something reasonable, like so: #define SWITCH switch( #define IN ){ #define ENDSW } #define FOR for( #define WHILE while( #define DO ){ #define ANDF && ... The resulting PHP DSL is clearly more consistent, and onboarding new devs is easy if they have some experience with ALGOL-family languages: <?php BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT PUNCH(3),??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),SAMELINE,ALIGNED(1,6),A,B,C' END' END' ?><|eor|><|sor|>To all the people down-voting our company's PHP DSL example, I'm putting you on a list for our hiring manager!<|eor|><|sor|>Positively or negatively? Real question - if your answer is "negatively" please go to the bar, have a couple drinks, quit your terrible job and maybe see a therapist. <|eor|><|sor|>The posts were meant as a joke, but I think my sense of humour is too dry for /r/lolphp (the **lol** in the subreddit name seems to be a misnomer). [Stephen Bourne](https://en.wikipedia.org/wiki/Stephen_R._Bourne) wrote the original shell utility for System V Unix while he worked at Bell Labs in the early '70s. He preferred Pascal to C, so he rewrote the C language via `#defines` to allow him to write the shell in ALGOL syntax. If you spend time digging through the source of commercial Unixes or \*BSDs (which is a common rite-of-passage in those OSs as the kernel and `world` are generally compiled from source, and the Bourne Shell is the standard shell vs. BASH in Linux-land), you'll eventually come across the `/bin/sh` source and have a first reaction of wtf?!? It *looks* like C, but it isn't! I've done what I described before with PHP as a joke entry in coding contests. I thought the joke on-topic to OPs question about PHP DSLs. The follow-up comment was a joke about all of the "industry leaders" who end up twittering that they'll never hire a whole group of people at their companies for X-Y-Z comments the people made on Twitter. It's happened enough times to at least be a solid meme on 4chan at this point. Anyways, I'm a nerd. I never could tell a joke, and either (a) /r/lolphp/lacks/lulz, or more likely (b) I still can't tell a joke.<|eor|><|sor|>Fuck me that's awesome. I was concerned for my own well being after seeing the OP I replied to being so well laid out and equally insane, glad to hear you're not out of your god damn mind!<|eor|><|eoss|><|endoftext|>
12
lolphp
mikeputerbaugh
dvw9jee
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>Creating your own domain-specific syntax for each task is more of a RoR thing<|eor|><|eoss|><|endoftext|>
7
lolphp
eth4n_
dvwjpmh
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>[BobX? I remember the thedailywtf post from back in the day.](http://thedailywtf.com/articles/We-Use-BobX)<|eor|><|soopr|>aye thanks, that is what i was looking for +1<|eoopr|><|eoss|><|endoftext|>
7
lolphp
ZiggyTheHamster
dvxft8e
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>[BobX? I remember the thedailywtf post from back in the day.](http://thedailywtf.com/articles/We-Use-BobX)<|eor|><|soopr|>aye thanks, that is what i was looking for +1<|eoopr|><|sor|>Not PHP but also worth mentioning: [JDSL or "the inner json effect"](http://thedailywtf.com/articles/the-inner-json-effect)<|eor|><|sor|>This can't be real. How would you do code review if a new revision can break the application in production automatically?<|eor|><|eoss|><|endoftext|>
7
lolphp
WikiTextBot
dvwxoyl
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>Why is it a "horror story"? Some people just don't like PHP's inconsistent syntax. I usually write PHP code with a macro preprocessor like [ccpp](https://github.com/metala/ccpp) and a build step. I use Ant to pull in a definition file for the preprocessor that replaces PHP's horrid syntax with something reasonable, like so: #define SWITCH switch( #define IN ){ #define ENDSW } #define FOR for( #define WHILE while( #define DO ){ #define ANDF && ... The resulting PHP DSL is clearly more consistent, and onboarding new devs is easy if they have some experience with ALGOL-family languages: <?php BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT PUNCH(3),??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),SAMELINE,ALIGNED(1,6),A,B,C' END' END' ?><|eor|><|sor|>To all the people down-voting our company's PHP DSL example, I'm putting you on a list for our hiring manager!<|eor|><|sor|>Positively or negatively? Real question - if your answer is "negatively" please go to the bar, have a couple drinks, quit your terrible job and maybe see a therapist. <|eor|><|sor|>The posts were meant as a joke, but I think my sense of humour is too dry for /r/lolphp (the **lol** in the subreddit name seems to be a misnomer). [Stephen Bourne](https://en.wikipedia.org/wiki/Stephen_R._Bourne) wrote the original shell utility for System V Unix while he worked at Bell Labs in the early '70s. He preferred Pascal to C, so he rewrote the C language via `#defines` to allow him to write the shell in ALGOL syntax. If you spend time digging through the source of commercial Unixes or \*BSDs (which is a common rite-of-passage in those OSs as the kernel and `world` are generally compiled from source, and the Bourne Shell is the standard shell vs. BASH in Linux-land), you'll eventually come across the `/bin/sh` source and have a first reaction of wtf?!? It *looks* like C, but it isn't! I've done what I described before with PHP as a joke entry in coding contests. I thought the joke on-topic to OPs question about PHP DSLs. The follow-up comment was a joke about all of the "industry leaders" who end up twittering that they'll never hire a whole group of people at their companies for X-Y-Z comments the people made on Twitter. It's happened enough times to at least be a solid meme on 4chan at this point. Anyways, I'm a nerd. I never could tell a joke, and either (a) /r/lolphp/lacks/lulz, or more likely (b) I still can't tell a joke.<|eor|><|sor|>**Stephen R. Bourne** Stephen Richard "Steve" Bourne (born 7 January 1944) is a computer scientist, originally from the United Kingdom and based in the United States for most of his career. He is well-known as the author of the Bourne shell (sh), which is the foundation for the standard command line interfaces to Unix. *** ^[ [^PM](https://www.reddit.com/message/compose?to=kittens_from_space) ^| [^Exclude ^me](https://reddit.com/message/compose?to=WikiTextBot&message=Excludeme&subject=Excludeme) ^| [^Exclude ^from ^subreddit](https://np.reddit.com/r/lolphp/about/banned) ^| [^FAQ ^/ ^Information](https://np.reddit.com/r/WikiTextBot/wiki/index) ^| [^Source](https://github.com/kittenswolf/WikiTextBot) ^| [^Donate](https://www.reddit.com/r/WikiTextBot/wiki/donate) ^] ^Downvote ^to ^remove ^| ^v0.28<|eor|><|eoss|><|endoftext|>
7
lolphp
commitpushdrink
dvwx572
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>Why is it a "horror story"? Some people just don't like PHP's inconsistent syntax. I usually write PHP code with a macro preprocessor like [ccpp](https://github.com/metala/ccpp) and a build step. I use Ant to pull in a definition file for the preprocessor that replaces PHP's horrid syntax with something reasonable, like so: #define SWITCH switch( #define IN ){ #define ENDSW } #define FOR for( #define WHILE while( #define DO ){ #define ANDF && ... The resulting PHP DSL is clearly more consistent, and onboarding new devs is easy if they have some experience with ALGOL-family languages: <?php BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT PUNCH(3),??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),SAMELINE,ALIGNED(1,6),A,B,C' END' END' ?><|eor|><|sor|>To all the people down-voting our company's PHP DSL example, I'm putting you on a list for our hiring manager!<|eor|><|sor|>Positively or negatively? Real question - if your answer is "negatively" please go to the bar, have a couple drinks, quit your terrible job and maybe see a therapist. <|eor|><|eoss|><|endoftext|>
6
lolphp
calligraphic-io
dvwy5ut
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>Why is it a "horror story"? Some people just don't like PHP's inconsistent syntax. I usually write PHP code with a macro preprocessor like [ccpp](https://github.com/metala/ccpp) and a build step. I use Ant to pull in a definition file for the preprocessor that replaces PHP's horrid syntax with something reasonable, like so: #define SWITCH switch( #define IN ){ #define ENDSW } #define FOR for( #define WHILE while( #define DO ){ #define ANDF && ... The resulting PHP DSL is clearly more consistent, and onboarding new devs is easy if they have some experience with ALGOL-family languages: <?php BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT PUNCH(3),??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),SAMELINE,ALIGNED(1,6),A,B,C' END' END' ?><|eor|><|sor|>To all the people down-voting our company's PHP DSL example, I'm putting you on a list for our hiring manager!<|eor|><|sor|>Positively or negatively? Real question - if your answer is "negatively" please go to the bar, have a couple drinks, quit your terrible job and maybe see a therapist. <|eor|><|sor|>The posts were meant as a joke, but I think my sense of humour is too dry for /r/lolphp (the **lol** in the subreddit name seems to be a misnomer). [Stephen Bourne](https://en.wikipedia.org/wiki/Stephen_R._Bourne) wrote the original shell utility for System V Unix while he worked at Bell Labs in the early '70s. He preferred Pascal to C, so he rewrote the C language via `#defines` to allow him to write the shell in ALGOL syntax. If you spend time digging through the source of commercial Unixes or \*BSDs (which is a common rite-of-passage in those OSs as the kernel and `world` are generally compiled from source, and the Bourne Shell is the standard shell vs. BASH in Linux-land), you'll eventually come across the `/bin/sh` source and have a first reaction of wtf?!? It *looks* like C, but it isn't! I've done what I described before with PHP as a joke entry in coding contests. I thought the joke on-topic to OPs question about PHP DSLs. The follow-up comment was a joke about all of the "industry leaders" who end up twittering that they'll never hire a whole group of people at their companies for X-Y-Z comments the people made on Twitter. It's happened enough times to at least be a solid meme on 4chan at this point. Anyways, I'm a nerd. I never could tell a joke, and either (a) /r/lolphp/lacks/lulz, or more likely (b) I still can't tell a joke.<|eor|><|sor|>**Stephen R. Bourne** Stephen Richard "Steve" Bourne (born 7 January 1944) is a computer scientist, originally from the United Kingdom and based in the United States for most of his career. He is well-known as the author of the Bourne shell (sh), which is the foundation for the standard command line interfaces to Unix. *** ^[ [^PM](https://www.reddit.com/message/compose?to=kittens_from_space) ^| [^Exclude ^me](https://reddit.com/message/compose?to=WikiTextBot&message=Excludeme&subject=Excludeme) ^| [^Exclude ^from ^subreddit](https://np.reddit.com/r/lolphp/about/banned) ^| [^FAQ ^/ ^Information](https://np.reddit.com/r/WikiTextBot/wiki/index) ^| [^Source](https://github.com/kittenswolf/WikiTextBot) ^| [^Donate](https://www.reddit.com/r/WikiTextBot/wiki/donate) ^] ^Downvote ^to ^remove ^| ^v0.28<|eor|><|sor|>good bot!<|eor|><|eoss|><|endoftext|>
6
lolphp
calligraphic-io
dvx1pr8
<|soss|><|sot|>looking for story: employee creates own php syntax<|eot|><|sost|>Hi folks, I am looking for a post/story (here in reddit or internet) about a php dev telling about a new job where he found that a former employee of the company created his own php syntax to code. The companies webpage (or shop system) is build on this custom syntax (like programming your webpage completly in smarty template engine). Furthermore, most of the infrastructure is still hosted on the former employee's side who warns the company to shut down the servers as he finds out, that this new php dev tries to "break out" of this custom syntax container. Its kind of a horror story for all the ppl trying to come up with a custom template engine or enhance a templating engine to run as an own language. Told a friend of mine about this story which I read years ago and didn't manage to find it. Can anybody help? regards<|eost|><|sor|>Why is it a "horror story"? Some people just don't like PHP's inconsistent syntax. I usually write PHP code with a macro preprocessor like [ccpp](https://github.com/metala/ccpp) and a build step. I use Ant to pull in a definition file for the preprocessor that replaces PHP's horrid syntax with something reasonable, like so: #define SWITCH switch( #define IN ){ #define ENDSW } #define FOR for( #define WHILE while( #define DO ){ #define ANDF && ... The resulting PHP DSL is clearly more consistent, and onboarding new devs is easy if they have some experience with ALGOL-family languages: <?php BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT PUNCH(3),??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),SAMELINE,ALIGNED(1,6),A,B,C' END' END' ?><|eor|><|sor|>To all the people down-voting our company's PHP DSL example, I'm putting you on a list for our hiring manager!<|eor|><|sor|>Positively or negatively? Real question - if your answer is "negatively" please go to the bar, have a couple drinks, quit your terrible job and maybe see a therapist. <|eor|><|sor|>The posts were meant as a joke, but I think my sense of humour is too dry for /r/lolphp (the **lol** in the subreddit name seems to be a misnomer). [Stephen Bourne](https://en.wikipedia.org/wiki/Stephen_R._Bourne) wrote the original shell utility for System V Unix while he worked at Bell Labs in the early '70s. He preferred Pascal to C, so he rewrote the C language via `#defines` to allow him to write the shell in ALGOL syntax. If you spend time digging through the source of commercial Unixes or \*BSDs (which is a common rite-of-passage in those OSs as the kernel and `world` are generally compiled from source, and the Bourne Shell is the standard shell vs. BASH in Linux-land), you'll eventually come across the `/bin/sh` source and have a first reaction of wtf?!? It *looks* like C, but it isn't! I've done what I described before with PHP as a joke entry in coding contests. I thought the joke on-topic to OPs question about PHP DSLs. The follow-up comment was a joke about all of the "industry leaders" who end up twittering that they'll never hire a whole group of people at their companies for X-Y-Z comments the people made on Twitter. It's happened enough times to at least be a solid meme on 4chan at this point. Anyways, I'm a nerd. I never could tell a joke, and either (a) /r/lolphp/lacks/lulz, or more likely (b) I still can't tell a joke.<|eor|><|sor|>Fuck me that's awesome. I was concerned for my own well being after seeing the OP I replied to being so well laid out and equally insane, glad to hear you're not out of your god damn mind!<|eor|><|sor|>thanks :)<|eor|><|eoss|><|endoftext|>
5
lolphp
Takeoded
6akjgv
<|sols|><|sot|>numeric keys can be confusing<|eot|><|sol|>https://3v4l.org/vQCck<|eol|><|eols|><|endoftext|>
28
lolphp
Takeoded
4mkj7w
<|soss|><|sot|>str_repeat returns NULL on failure<|eot|><|sost|>unlike pretty much everything else in PHP, which returns FALSE for failure, str_repeat returns NULL. also it's undocumented. <?php var_dump(str_repeat('fo',-1));?> >Warning: str_repeat(): Second argument has to be greater than or equal to 0 in /in/IuEhp on line 1 > >NULL<|eost|><|eoss|><|endoftext|>
27