subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
MiyatodukenMiyamaap
ck03yt3
<|sols|><|sot|>stdClass is truthy while an empty SimpleXMLElement is falsey<|eot|><|sol|>http://3v4l.org/3hWSY<|eol|><|sor|>I don't know if the fact that SimpleXMLElement is a [documented special case](http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting) makes it more or less perplexing. (If it makes you feel any better, that StdClass would have been fasley in PHP 4, which would have been... more consistent? less consistent? less nonsensical? none of the above? I don't know.)<|eor|><|soopr|>I'd definitely say inconsistent. You can't document your way out of inconsistency even though the PHP team likes to think so. Here's another one: $arr = array('first', 'foo' => 'second', 'third'); list($a, $b) = $arr; echo "$a $b"; foreach($arr as $val) {echo "$val";} What's the result? You might have the correct answer, but you'd be lying if you said you didn't have to think about it - and that's exactly the problem. These ambiguities make you mistrust the language and make you doubt your own code.<|eoopr|><|sor|>Ha! I actually don't know the answer off the top of my head, but I do remember being asked something very similar in a job interview once. My response was something along the lines of "Who cares? Don't do that!" Mixing implicit numeric keys and explicit string keys in the same array is a silly thing to do, and I guess PHP figures it can't be held responsible for the silly outcomes resulting from the silly things it allows. I didn't get the job, but I stand by my answer :).<|eor|><|eols|><|endoftext|>
11
lolphp
MiyatodukenMiyamaap
ck01dvl
<|sols|><|sot|>stdClass is truthy while an empty SimpleXMLElement is falsey<|eot|><|sol|>http://3v4l.org/3hWSY<|eol|><|sor|>I don't know if the fact that SimpleXMLElement is a [documented special case](http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting) makes it more or less perplexing. (If it makes you feel any better, that StdClass would have been fasley in PHP 4, which would have been... more consistent? less consistent? less nonsensical? none of the above? I don't know.)<|eor|><|eols|><|endoftext|>
10
lolphp
BufferUnderpants
ck0dmtv
<|sols|><|sot|>stdClass is truthy while an empty SimpleXMLElement is falsey<|eot|><|sol|>http://3v4l.org/3hWSY<|eol|><|sor|>I don't know if the fact that SimpleXMLElement is a [documented special case](http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting) makes it more or less perplexing. (If it makes you feel any better, that StdClass would have been fasley in PHP 4, which would have been... more consistent? less consistent? less nonsensical? none of the above? I don't know.)<|eor|><|sor|>> I don't know if the fact that SimpleXMLElement is a **documented** There we have it, folks. It's *documented*. That right there closes the discussion. Nothing to see here, move along.<|eor|><|eols|><|endoftext|>
9
lolphp
himdel
ck02ul4
<|sols|><|sot|>stdClass is truthy while an empty SimpleXMLElement is falsey<|eot|><|sol|>http://3v4l.org/3hWSY<|eol|><|sor|>Ooh, I'd love a way to make specific objects falsy, but no, of course it being PHP, it must be a special case. <|eor|><|eols|><|endoftext|>
6
lolphp
andsens
ck0ee2c
<|sols|><|sot|>stdClass is truthy while an empty SimpleXMLElement is falsey<|eot|><|sol|>http://3v4l.org/3hWSY<|eol|><|sor|>I'm pretty sure it's because `SimpleXMLElement` casts `__toString()` which returns the content of the node and since the node is empty, it returns false. stdClass doesn't have a `__toString`, so it returns true for being an object, but not sure how that's determined.<|eor|><|soopr|>Nope, [that's not it](http://3v4l.org/4Xk4v).<|eoopr|><|eols|><|endoftext|>
5
lolphp
gearvOsh
ck0egyu
<|sols|><|sot|>stdClass is truthy while an empty SimpleXMLElement is falsey<|eot|><|sol|>http://3v4l.org/3hWSY<|eol|><|sor|>I'm pretty sure it's because `SimpleXMLElement` casts `__toString()` which returns the content of the node and since the node is empty, it returns false. stdClass doesn't have a `__toString`, so it returns true for being an object, but not sure how that's determined.<|eor|><|soopr|>Nope, [that's not it](http://3v4l.org/4Xk4v).<|eoopr|><|sor|>Looks like SimpleXML has a special case: http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting Guessing all objects return true otherwise.<|eor|><|eols|><|endoftext|>
5
lolphp
andsens
ck0ezou
<|sols|><|sot|>stdClass is truthy while an empty SimpleXMLElement is falsey<|eot|><|sol|>http://3v4l.org/3hWSY<|eol|><|sor|>I'm pretty sure it's because `SimpleXMLElement` casts `__toString()` which returns the content of the node and since the node is empty, it returns false. stdClass doesn't have a `__toString`, so it returns true for being an object, but not sure how that's determined.<|eor|><|soopr|>Nope, [that's not it](http://3v4l.org/4Xk4v).<|eoopr|><|sor|>Looks like SimpleXML has a special case: http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting Guessing all objects return true otherwise.<|eor|><|soopr|>I'd call that a "speciuhl" case :-)<|eoopr|><|eols|><|endoftext|>
5
lolphp
CoenJacobs
2df8v5
<|sols|><|sot|>Wonder how many people have run phpinfo in 3v4l.org already...<|eot|><|sol|>http://3v4l.org/1l50A<|eol|><|eols|><|endoftext|>
22
lolphp
DoctorWaluigiTime
cjoyzot
<|sols|><|sot|>Wonder how many people have run phpinfo in 3v4l.org already...<|eot|><|sol|>http://3v4l.org/1l50A<|eol|><|sor|>Even though it has a mechanism in place to detect and stop abuse, you'd think `phpinfo()` would be a blacklisted function.<|eor|><|eols|><|endoftext|>
9
lolphp
shitcanz
m3bwl7
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|eoss|><|endoftext|>
22
lolphp
tdammers
gqo0rtd
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>> Please devs, just focus on having unicode support. 1. bUt pHP hAs UnIcOdE sUpPoRt 2. "Unicode is too damn hard. We tried it. It didn't work."<|eor|><|eoss|><|endoftext|>
30
lolphp
ZiggyTheHamster
gqo7q8w
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>Not to defend PHP here, but the whole point of fibers in this context is to make it possible to run some code, which doesn't have to run this exact moment, and then wait for it to complete (or run many pieces of code which can run in any order or at the same time). Yes, IO would block the entire process, but if you built something that broke off an IO task (or many IO tasks) into fibers, you don't need to necessarily care when the IO blocks. PHP could at some point change to using aio_write or write+select/poll APIs, and while it's waiting for the IO to occur, instead of sitting there as it does now, it could work on other fibers. Each fiber is essentially synchronous inside, but the interpreter can run many of them at the same time (as long as nobody mutates shared state at the same time). If one pauses (because the synchronous API it called is actually using an async API internally), then it works on another fiber. It's not the best thing in the world, but it allows them to potentially introduce non-blocking IO for a throughput increase. That said though, I had no idea they still haven't solved the Unicode problem yet. In Ruby, it's transparent. Ruby 1.8 required you to pick an encoding and stick with it, but that was like a decade ago. Ever since 1.9, strings just track the encoding they are, and everything else is automatic. You just run into issues when you try to concatenate two strings with different encodings, which would be obviously bad. I guess the difference is that Ruby doesn't have any scalar types; everything is an object instance.<|eor|><|eoss|><|endoftext|>
22
lolphp
sproingie
gqplo5m
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>So PHP adding a major feature is a LOL. I guess async I/O APIs never should have come to C because it wasn't in stdio originally.<|eor|><|eoss|><|endoftext|>
19
lolphp
cangelis
gqoci32
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>What do you mean by it starts and dies instantly? PHP is also used for long running CLI apps such as queue workers, cron jobs, dev servers etc.<|eor|><|eoss|><|endoftext|>
17
lolphp
stfcfanhazz
gqohn66
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>What do you mean by it starts and dies instantly? PHP is also used for long running CLI apps such as queue workers, cron jobs, dev servers etc.<|eor|><|soopr|>What i mean is PHP is never running. Its lifecycle is very short. Its boots (loads all dependencies), runs and then terminates. You really cant have a long running PHP process in say a web context, like a socket connection. The only way to accomplish this is to use an external library that literally changes the way PHP was ment to execute. When using something like reactphp that mimics node with its own eventloop you loose all the core features of PHP. Additionally, i am unaware of what additional dependencies reactphp-like libraries introduce? Is the core eventloop using libuv? If not what is it using? PHP is also used for long running CLI apps such as queue workers, cron jobs, dev servers etc. A long running process, is not "one that takes X seconds to finish". A long running process is something like a socket-server thats running for years.<|eoopr|><|sor|>That's actually not entirely true- it's how PHP is most commonly used at the moment, but this RFC aims to make it easier to implement an async/long-running execution model. There are already 3rd party packages / extensions (think amp, swoole etc) which provide this ability using event loops / process forking / php generators (yield syntax), but these approaches are a little clunky. This fibers RFC is a good thing for the language since it opens up the door towards a native async/await/promise API.<|eor|><|eoss|><|endoftext|>
13
lolphp
Dr_Azrael_Tod
gqomjmk
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>What do you mean by it starts and dies instantly? PHP is also used for long running CLI apps such as queue workers, cron jobs, dev servers etc.<|eor|><|sor|>don't remind me! had to try to fix a project once where a coworker of mine thought it'd be a good idea to write a server, listening on a socket, in PHP. It worked on all his unit and integration tests (haha as if he'd ever wrote those), but it just never occured to him that there might be two or more clients connected at the same time.<|eor|><|eoss|><|endoftext|>
10
lolphp
stfcfanhazz
gqokrm8
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>What do you mean by it starts and dies instantly? PHP is also used for long running CLI apps such as queue workers, cron jobs, dev servers etc.<|eor|><|soopr|>What i mean is PHP is never running. Its lifecycle is very short. Its boots (loads all dependencies), runs and then terminates. You really cant have a long running PHP process in say a web context, like a socket connection. The only way to accomplish this is to use an external library that literally changes the way PHP was ment to execute. When using something like reactphp that mimics node with its own eventloop you loose all the core features of PHP. Additionally, i am unaware of what additional dependencies reactphp-like libraries introduce? Is the core eventloop using libuv? If not what is it using? PHP is also used for long running CLI apps such as queue workers, cron jobs, dev servers etc. A long running process, is not "one that takes X seconds to finish". A long running process is something like a socket-server thats running for years.<|eoopr|><|sor|>That's actually not entirely true- it's how PHP is most commonly used at the moment, but this RFC aims to make it easier to implement an async/long-running execution model. There are already 3rd party packages / extensions (think amp, swoole etc) which provide this ability using event loops / process forking / php generators (yield syntax), but these approaches are a little clunky. This fibers RFC is a good thing for the language since it opens up the door towards a native async/await/promise API.<|eor|><|soopr|>Well its true in the sense that 99.99% of PHP runs this was. The entire ecosystem is built around this singe core principle. Having PHP running a server for longer periods is just not worth it. You loose the entire PHP ecosystem, and are now forced to use even more dependencies (php projects already have a huge amount to begin with).<|eoopr|><|sor|>You don't lose anything. It's a stepping stone in the direction of supporting an alternative execution model- nobody will be forced to pick one over the other and it depends entirely on use case<|eor|><|eoss|><|endoftext|>
10
lolphp
cangelis
gqoito9
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>What do you mean by it starts and dies instantly? PHP is also used for long running CLI apps such as queue workers, cron jobs, dev servers etc.<|eor|><|soopr|>What i mean is PHP is never running. Its lifecycle is very short. Its boots (loads all dependencies), runs and then terminates. You really cant have a long running PHP process in say a web context, like a socket connection. The only way to accomplish this is to use an external library that literally changes the way PHP was ment to execute. When using something like reactphp that mimics node with its own eventloop you loose all the core features of PHP. Additionally, i am unaware of what additional dependencies reactphp-like libraries introduce? Is the core eventloop using libuv? If not what is it using? PHP is also used for long running CLI apps such as queue workers, cron jobs, dev servers etc. A long running process, is not "one that takes X seconds to finish". A long running process is something like a socket-server thats running for years.<|eoopr|><|sor|>>You really cant have a long running PHP process in say a web context, like a socket connection. Web apps don't consist of HTTP request handling only. Queue workers, cron jobs, real-time request handlers, websocket apps are also part of a web app. >A long running process is something like a socket-server thats running for years. That's what queue workers and websocket apps do.<|eor|><|eoss|><|endoftext|>
9
lolphp
elcapitanoooo
gqqgskn
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>So PHP adding a major feature is a LOL. I guess async I/O APIs never should have come to C because it wasn't in stdio originally.<|eor|><|sor|> Major feature that is incompatible with every IO operation. PHP is a high level language, built for http. The concurrency is pushed to the server, and was never ment to be handled in userland code. Coming years will be fun. So much more bugs and issues when this get released and people start mixing this in with their wordpress sites. Popcorn.<|eor|><|eoss|><|endoftext|>
8
lolphp
stfcfanhazz
gqoknkj
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>[deleted]<|eor|><|soopr|>What has PSR-7 have to do with async IO?, Nerd?<|eoopr|><|sor|>I think he's reading behind the lines in your post. If you rely on PHP's request superglobals ($_GET, $_SERVER etc) then no wonder you can't understand the potential of the fibers RFC. Running PHP as an async server means you can't use these sorts of shared state global vars of course, which is one of the "issues" that PSR-7 implementations solve since they represent http requests in a single locally scoped object, meaning its possible to handle multiple requests asynchronously.<|eor|><|soopr|>Where did i mention superglobals? I said i cant use any of the PHP builtins, like disk IO, or the builtin PDO library. This has nothing to do with PSR, and is in no way related.<|eoopr|><|sor|>Reading between the lines<|eor|><|eoss|><|endoftext|>
8
lolphp
cq73
gqp6dgy
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>The PHP future development timeline is like a perfect case study to demonstrate the sunk cost fallacy.<|eor|><|eoss|><|endoftext|>
7
lolphp
elcapitanoooo
gqok7qf
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>LOL. I posted this exact same issue on the php subreddit, and got a myriad of weak answers. It seems that the PHP users on that reddit has no clue on how a callback based event loop works (i assume thats what they want to have in php, more accurately a nodejs like clone). Basically i got downvoted, and every answer was "But you can install this aw3s0mn355 hyped thing that allows a callback like syntax". Not one answer did acknowledge that any core IO is a real hazard to use, in fact using something like this will have a huge risk for future crashes and downtime, simply because its too easy to block the event loop. The same can be said for nodejs, but its much harder because the language was designed for callback based IO, really the only way to block is having a CPU intensive function running. As i see it, this adds the worst combinations to PHP. 1. Goes against PHP philosophy of execution 2. Makes any native IO related functionality unusable 3. Introduces a high probability for bugs and crashes (blocking main thread) 4. Is useless for 99.99% of the PHP ecosystem 5. Splits the ecosystem in two (async vs sync) 6. Needs a new stdlib for IO code using async<|eor|><|eoss|><|endoftext|>
6
lolphp
merreborn
gqpyzfb
<|soss|><|sot|>PHP fibers<|eot|><|sost|>Proposal: https://wiki.php.net/rfc/fibers The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively". LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client. LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO. Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.<|eost|><|sor|>Not to defend PHP here, but the whole point of fibers in this context is to make it possible to run some code, which doesn't have to run this exact moment, and then wait for it to complete (or run many pieces of code which can run in any order or at the same time). Yes, IO would block the entire process, but if you built something that broke off an IO task (or many IO tasks) into fibers, you don't need to necessarily care when the IO blocks. PHP could at some point change to using aio_write or write+select/poll APIs, and while it's waiting for the IO to occur, instead of sitting there as it does now, it could work on other fibers. Each fiber is essentially synchronous inside, but the interpreter can run many of them at the same time (as long as nobody mutates shared state at the same time). If one pauses (because the synchronous API it called is actually using an async API internally), then it works on another fiber. It's not the best thing in the world, but it allows them to potentially introduce non-blocking IO for a throughput increase. That said though, I had no idea they still haven't solved the Unicode problem yet. In Ruby, it's transparent. Ruby 1.8 required you to pick an encoding and stick with it, but that was like a decade ago. Ever since 1.9, strings just track the encoding they are, and everything else is automatic. You just run into issues when you try to concatenate two strings with different encodings, which would be obviously bad. I guess the difference is that Ruby doesn't have any scalar types; everything is an object instance.<|eor|><|sor|>The "why even bother when it's not a real thread" discussion reminds me of cpython's [global interpreter lock](https://en.wikipedia.org/wiki/Global_interpreter_lock) pseudo-parallelism can be a useful tool, in the right context.<|eor|><|eoss|><|endoftext|>
6
lolphp
aleczapka
itsn91
<|sols|><|sot|>DateTime::createFromFormat('lol', microtime(maybe))<|eot|><|sol|>https://3v4l.org/9PN0m<|eol|><|eols|><|endoftext|>
22
lolphp
aleczapka
g5ghazl
<|sols|><|sot|>DateTime::createFromFormat('lol', microtime(maybe))<|eot|><|sol|>https://3v4l.org/9PN0m<|eol|><|soopr|>In those rare cases when `microtime(true)` call will return `SOME_UNIX_TIMESTAMP.000000)` where microseconds are set to 0 (ye can really happen) cause that was actually the ...time. After that its easy: it gets float where the "padding" 0 are cut away for "reasons" and the string is converted to `SOME_UNIX_TIMESTAMP` instead of `SOME_UNIX_TIMESTAMP.000000` and you have a bug on production and your manager is yelling at you.. that's php folks<|eoopr|><|eols|><|endoftext|>
6
lolphp
elcapitanoooo
g5i9dqy
<|sols|><|sot|>DateTime::createFromFormat('lol', microtime(maybe))<|eot|><|sol|>https://3v4l.org/9PN0m<|eol|><|soopr|>In those rare cases when `microtime(true)` call will return `SOME_UNIX_TIMESTAMP.000000)` where microseconds are set to 0 (ye can really happen) cause that was actually the ...time. After that its easy: it gets float where the "padding" 0 are cut away for "reasons" and the string is converted to `SOME_UNIX_TIMESTAMP` instead of `SOME_UNIX_TIMESTAMP.000000` and you have a bug on production and your manager is yelling at you.. that's php folks<|eoopr|><|sor|>One of my friends who work with PHP told me they have a rule that anything time related can NEVER be implemented in PHP. They actually have microservices with http endpoints for time stuff. Talk about lolphp.<|eor|><|eols|><|endoftext|>
6
lolphp
Jinxuan
gsz56h
<|soss|><|sot|>number_format allows 2 arguments or 4 arguments, but disallows 3 arguments<|eot|><|sost|>As the document says [https://www.php.net/manual/en/function.number-format.php](https://www.php.net/manual/en/function.number-format.php), the function is like ``` number_format ( float $number [, int $decimals = 0 ] ) : string number_format ( float $number , int $decimals = 0 , string $dec_point = "." , string $thousands_sep = "," ) : string ``` One may naively think that `number_format(1.99, 2, '.');` is legal, taking the forth argument default as ",". But it will generate an warning and return null `PHP Warning: Wrong parameter count for number_format() `<|eost|><|eoss|><|endoftext|>
21
lolphp
maxgee
fs9hgen
<|soss|><|sot|>number_format allows 2 arguments or 4 arguments, but disallows 3 arguments<|eot|><|sost|>As the document says [https://www.php.net/manual/en/function.number-format.php](https://www.php.net/manual/en/function.number-format.php), the function is like ``` number_format ( float $number [, int $decimals = 0 ] ) : string number_format ( float $number , int $decimals = 0 , string $dec_point = "." , string $thousands_sep = "," ) : string ``` One may naively think that `number_format(1.99, 2, '.');` is legal, taking the forth argument default as ",". But it will generate an warning and return null `PHP Warning: Wrong parameter count for number_format() `<|eost|><|sor|>[deleted]<|eor|><|sor|>it's not. this person likes to post a lot of bad examples in this sub<|eor|><|eoss|><|endoftext|>
11
lolphp
nplus
6gt51x
<|sols|><|sot|>A Comic About PHP Good Parts<|eot|><|sol|>https://turnoff.us/geek/php-good-parts/<|eol|><|eols|><|endoftext|>
18
lolphp
seriouslulz
4wpaek
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|eols|><|endoftext|>
22
lolphp
poop-trap
d691din
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>One thing that php got right is that it collected all these devs in one place so that the rest of us don't have to deal with them.<|eor|><|eols|><|endoftext|>
43
lolphp
Bl00dsoul
d69gy6q
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|eols|><|endoftext|>
23
lolphp
BufferUnderpants
d69iv92
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|sor|>I agree. It's the one notable good decision in PHP, even if it was lifted from Perl. Using ```+``` for operations that aren't commutative is nothing to celebrate or demand from a language.<|eor|><|eols|><|endoftext|>
13
lolphp
seriouslulz
d69io41
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|soopr|>> It's ridiculous. Any language in which "1" + "1" equals 2 is insane.<|eoopr|><|eols|><|endoftext|>
10
lolphp
vytah
d69opqa
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|soopr|>> It's ridiculous. Any language in which "1" + "1" equals 2 is insane.<|eoopr|><|sor|>Addition is commutative. Concatenation is not commutative. I see no reason to use the same symbol for both. Haskell uses `++` for list concatenation and `<>` for the monoid operation (which for list-like structures is concatenation). Many other languages also use different operators for string concatenation: D uses `~`. Lua uses `..`. SQL uses `||`. OCaml uses `^`. Therefore, Perl and PHP's `.` is also fine.<|eor|><|eols|><|endoftext|>
9
lolphp
seriouslulz
d69pp5g
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|soopr|>> It's ridiculous. Any language in which "1" + "1" equals 2 is insane.<|eoopr|><|sor|>Addition is commutative. Concatenation is not commutative. I see no reason to use the same symbol for both. Haskell uses `++` for list concatenation and `<>` for the monoid operation (which for list-like structures is concatenation). Many other languages also use different operators for string concatenation: D uses `~`. Lua uses `..`. SQL uses `||`. OCaml uses `^`. Therefore, Perl and PHP's `.` is also fine.<|eor|><|soopr|>That's not the point. The point is anything operating on numbers and returning a string (or vice versa) is fucking insane.<|eoopr|><|eols|><|endoftext|>
8
lolphp
seriouslulz
d6a6hzr
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|soopr|>> It's ridiculous. Any language in which "1" + "1" equals 2 is insane.<|eoopr|><|sor|>The really insane thing is `"1foo" + "1bar"` evaluating to `2`. `"1" + "1"` being `2` is perfectly sane. In a dynamically typed language you have a couple of different design choices when adding strings together with `+`: 1. Produce a runtime error 2. Concatenate the strings 3. Convert the strings to number and add them together Option 1 is totally reasonable, but can be a bit annoying because it forces you to add lots of explicit coercions to your code. Option 2 means you add less operators to the language but has the downside that at compile time you have no idea what a `+` means. It could be addition or concatenation depending on the runtime values of your parameters. And in a dynamic language its easy to pass a number where a string is expected (or vice versa) and get strange results. Option 3 has the advantage that `+` always means numeric addition and `.` always means string concatenation. If coercing strings to numbers is reasonable (has an error if the string is has non-numeric characters) then its not gonna do anything that is really crazy.<|eor|><|soopr|>> `"1" + "1"` being `2` is perfectly sane. It's not though. I can't even think of a situation where that would be useful either, as it probably would mean you're not checking user input. Just do explicit type casting and save everyone a headache.<|eoopr|><|eols|><|endoftext|>
7
lolphp
n0t0ri0us9
d68zl05
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>Get out.<|eor|><|sor|>No. Why don't you get out? We are here to make fun of everything Php. If you are not Ok with it. Don't come here. Simple!<|eor|><|eols|><|endoftext|>
6
lolphp
coredumperror
d6si0u3
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|soopr|>> It's ridiculous. Any language in which "1" + "1" equals 2 is insane.<|eoopr|><|sor|>Addition is commutative. Concatenation is not commutative. I see no reason to use the same symbol for both. Haskell uses `++` for list concatenation and `<>` for the monoid operation (which for list-like structures is concatenation). Many other languages also use different operators for string concatenation: D uses `~`. Lua uses `..`. SQL uses `||`. OCaml uses `^`. Therefore, Perl and PHP's `.` is also fine.<|eor|><|soopr|>That's not the point. The point is anything operating on numbers and returning a string (or vice versa) is fucking insane.<|eoopr|><|sor|>Why? If it expects numbers, being able to use numeric strings is arguably helpful in some contexts.<|eor|><|sor|>The operative words being "arguably" and "some", while PHP decides that "always helpful in all contexts" was the right way to go.<|eor|><|eols|><|endoftext|>
6
lolphp
smog_alado
d6a0awt
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|soopr|>> It's ridiculous. Any language in which "1" + "1" equals 2 is insane.<|eoopr|><|sor|>The really insane thing is `"1foo" + "1bar"` evaluating to `2`. `"1" + "1"` being `2` is perfectly sane. In a dynamically typed language you have a couple of different design choices when adding strings together with `+`: 1. Produce a runtime error 2. Concatenate the strings 3. Convert the strings to number and add them together Option 1 is totally reasonable, but can be a bit annoying because it forces you to add lots of explicit coercions to your code. Option 2 means you add less operators to the language but has the downside that at compile time you have no idea what a `+` means. It could be addition or concatenation depending on the runtime values of your parameters. And in a dynamic language its easy to pass a number where a string is expected (or vice versa) and get strange results. Option 3 has the advantage that `+` always means numeric addition and `.` always means string concatenation. If coercing strings to numbers is reasonable (has an error if the string is has non-numeric characters) then its not gonna do anything that is really crazy.<|eor|><|eols|><|endoftext|>
5
lolphp
carlos_vini
d6dai82
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|soopr|>> It's ridiculous. Any language in which "1" + "1" equals 2 is insane.<|eoopr|><|sor|>The really insane thing is `"1foo" + "1bar"` evaluating to `2`. `"1" + "1"` being `2` is perfectly sane. In a dynamically typed language you have a couple of different design choices when adding strings together with `+`: 1. Produce a runtime error 2. Concatenate the strings 3. Convert the strings to number and add them together Option 1 is totally reasonable, but can be a bit annoying because it forces you to add lots of explicit coercions to your code. Option 2 means you add less operators to the language but has the downside that at compile time you have no idea what a `+` means. It could be addition or concatenation depending on the runtime values of your parameters. And in a dynamic language its easy to pass a number where a string is expected (or vice versa) and get strange results. Option 3 has the advantage that `+` always means numeric addition and `.` always means string concatenation. If coercing strings to numbers is reasonable (has an error if the string is has non-numeric characters) then its not gonna do anything that is really crazy.<|eor|><|sor|>"1foo" + "1bar" will be an error of type E_NOTICE in PHP 7.1: https://3v4l.org/WqonO "Notice: A non well formed numeric value encountered in /in/WqonO on line 3"<|eor|><|eols|><|endoftext|>
5
lolphp
seriouslulz
d6ixv3t
<|sols|><|sot|>More like lolphpdevs, but this fucking thread<|eot|><|sol|>https://www.reddit.com/r/ProgrammerHumor/comments/4wj23f/php_the_good_parts/d67ie00<|eol|><|sor|>I don't get it? not overloading the + operator for string concat was indeed a good idea. just look at javascript..<|eor|><|soopr|>> It's ridiculous. Any language in which "1" + "1" equals 2 is insane.<|eoopr|><|sor|>Addition is commutative. Concatenation is not commutative. I see no reason to use the same symbol for both. Haskell uses `++` for list concatenation and `<>` for the monoid operation (which for list-like structures is concatenation). Many other languages also use different operators for string concatenation: D uses `~`. Lua uses `..`. SQL uses `||`. OCaml uses `^`. Therefore, Perl and PHP's `.` is also fine.<|eor|><|soopr|>That's not the point. The point is anything operating on numbers and returning a string (or vice versa) is fucking insane.<|eoopr|><|sor|>You still don't want $a + $b to do completely different things depending on the contents, especially when they both look the same when printed. And for all the sins php has, making it easier to handle numeric input through text channels is not so bad. It's not a big problem for "5" to convert to 5. The real problem is when "h" converts to 0. That shouldn't be possible. Or when "4j" converts to 4.<|eor|><|soopr|>> You still don't want $a + $b to do completely different things depending on the contents, especially when they both look the same when printed. I don't see why since you're supposed to validate their contents. If you don't, you're already doing it wrong, so that would be the least of your problems.<|eoopr|><|eols|><|endoftext|>
5
lolphp
pilif
4gduzm
<|soss|><|sot|>Using traits enforces declaration order<|eot|><|sost|>Normally, in PHP, you're free to instantiate a subclass of a class that's not defined yet. Like this: https://3v4l.org/CXjt8 But the moment your subclass uses a trait, that's not true any more: https://3v4l.org/BXALN Of course that's working as intended: https://bugs.php.net/bug.php?id=70783<|eost|><|eoss|><|endoftext|>
21
lolphp
garagedragon
d2gvbp5
<|soss|><|sot|>Using traits enforces declaration order<|eot|><|sost|>Normally, in PHP, you're free to instantiate a subclass of a class that's not defined yet. Like this: https://3v4l.org/CXjt8 But the moment your subclass uses a trait, that's not true any more: https://3v4l.org/BXALN Of course that's working as intended: https://bugs.php.net/bug.php?id=70783<|eost|><|sor|>The best bit is that the error is reported on the line you declare the subclass. Yes, technically, that's where the error is, but if you suddenly encounter that message after adding a trait to your superclass, that's one heck of a spooky action at a distance. <|eor|><|eoss|><|endoftext|>
17
lolphp
arturaz
d2hjxd8
<|soss|><|sot|>Using traits enforces declaration order<|eot|><|sost|>Normally, in PHP, you're free to instantiate a subclass of a class that's not defined yet. Like this: https://3v4l.org/CXjt8 But the moment your subclass uses a trait, that's not true any more: https://3v4l.org/BXALN Of course that's working as intended: https://bugs.php.net/bug.php?id=70783<|eost|><|sor|>The real wtf is that you can extend a non existant class.<|eor|><|eoss|><|endoftext|>
14
lolphp
pilif
d2hk4ty
<|soss|><|sot|>Using traits enforces declaration order<|eot|><|sost|>Normally, in PHP, you're free to instantiate a subclass of a class that's not defined yet. Like this: https://3v4l.org/CXjt8 But the moment your subclass uses a trait, that's not true any more: https://3v4l.org/BXALN Of course that's working as intended: https://bugs.php.net/bug.php?id=70783<|eost|><|sor|>The real wtf is that you can extend a non existant class.<|eor|><|soopr|>It's similar to how you can call functions only defined later in the file (a feature I remember being happy about to be getting with PHP 4.0.0). PHP does two passes when parsing a file. <|eoopr|><|eoss|><|endoftext|>
7
lolphp
pilif
d2i57ob
<|soss|><|sot|>Using traits enforces declaration order<|eot|><|sost|>Normally, in PHP, you're free to instantiate a subclass of a class that's not defined yet. Like this: https://3v4l.org/CXjt8 But the moment your subclass uses a trait, that's not true any more: https://3v4l.org/BXALN Of course that's working as intended: https://bugs.php.net/bug.php?id=70783<|eost|><|sor|>The real wtf is that you can extend a non existant class.<|eor|><|soopr|>It's similar to how you can call functions only defined later in the file (a feature I remember being happy about to be getting with PHP 4.0.0). PHP does two passes when parsing a file. <|eoopr|><|sor|>You can call functions not defined anywhere, in fact. It'll error when the call is actually made.<|eor|><|soopr|>yeah. but if they are inside of the same file, you can call them before you have defined them: https://3v4l.org/Cma1X - this was an error in PHP-FI and PHP3 (yes. I'm a PHP user since the PHP-FI days) <|eoopr|><|eoss|><|endoftext|>
6
lolphp
nic0nic
345qcw
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|eols|><|endoftext|>
17
lolphp
McGlockenshire
cqrhvxl
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>Anonymous functions are just like normal functions when it comes to not inheriting variable scope. PHP is actually being consistent here. In PHP, you create a *closure over a scope* by using `use` to selectively pull in variables either at define time or at call time. This isn't lolphp, this is lolatleast*skim*themanual.<|eor|><|eols|><|endoftext|>
51
lolphp
cite-reader
cqrqwf9
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>Anonymous functions are just like normal functions when it comes to not inheriting variable scope. PHP is actually being consistent here. In PHP, you create a *closure over a scope* by using `use` to selectively pull in variables either at define time or at call time. This isn't lolphp, this is lolatleast*skim*themanual.<|eor|><|sor|>It's inconsistent with every other language I've ever used closures in, though, which I suspect is the point OP was making.<|eor|><|sor|>How about C++?<|eor|><|sor|>"C++ does it" is not, by itself, a convincing argument in favor of *anything.*<|eor|><|eols|><|endoftext|>
28
lolphp
barubary
cqrlxob
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>This is a consequence of PHP not having variable declarations (and every variable having function scope implicitly). Python has half of the same issue because half of its variables (those assigned to) are implicitly scoped to their containing function. Hence `nonlocal` in Python 3, equivalent to PHP's `use`. Most other languages that support closures (Haskell, Perl, JavaScript, ...) have explicit binders / variable declarations, so this is simply not an issue.<|eor|><|eols|><|endoftext|>
16
lolphp
scshunt
cqrqate
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>Anonymous functions are just like normal functions when it comes to not inheriting variable scope. PHP is actually being consistent here. In PHP, you create a *closure over a scope* by using `use` to selectively pull in variables either at define time or at call time. This isn't lolphp, this is lolatleast*skim*themanual.<|eor|><|sor|>It's inconsistent with every other language I've ever used closures in, though, which I suspect is the point OP was making.<|eor|><|sor|>How about C++?<|eor|><|eols|><|endoftext|>
16
lolphp
cite-reader
cqro7tp
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>Anonymous functions are just like normal functions when it comes to not inheriting variable scope. PHP is actually being consistent here. In PHP, you create a *closure over a scope* by using `use` to selectively pull in variables either at define time or at call time. This isn't lolphp, this is lolatleast*skim*themanual.<|eor|><|sor|>It's inconsistent with every other language I've ever used closures in, though, which I suspect is the point OP was making.<|eor|><|eols|><|endoftext|>
13
lolphp
cite-reader
cqro28g
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>This is a consequence of PHP not having variable declarations (and every variable having function scope implicitly). Python has half of the same issue because half of its variables (those assigned to) are implicitly scoped to their containing function. Hence `nonlocal` in Python 3, equivalent to PHP's `use`. Most other languages that support closures (Haskell, Perl, JavaScript, ...) have explicit binders / variable declarations, so this is simply not an issue.<|eor|><|sor|>Well, yes, but also no. Python requires `nonlocal` when you *set* a variable in the outer scope; reading it works fine: def const(x): return lambda _: x That works, and `const(42)(None)` evaluates to `42` as you would expect. PHP differs in that even *reading* the value requires explicitly closing over it. Oh, and yes; let's not forget that PHP closes over *by value*, which is not what you would expect from using closures in Ruby, Python, Javascript, any of the Lisps, et cetera. (Yes, I know how to recover the other semantics. Not the point.)<|eor|><|eols|><|endoftext|>
13
lolphp
Dworgi
cqrssyh
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>Anonymous functions are just like normal functions when it comes to not inheriting variable scope. PHP is actually being consistent here. In PHP, you create a *closure over a scope* by using `use` to selectively pull in variables either at define time or at call time. This isn't lolphp, this is lolatleast*skim*themanual.<|eor|><|sor|>It's inconsistent with every other language I've ever used closures in, though, which I suspect is the point OP was making.<|eor|><|sor|>How about C++?<|eor|><|sor|>"C++ does it" is not, by itself, a convincing argument in favor of *anything.*<|eor|><|sor|>What doesn't C++ do at this point? And in what way doesn't it do it? Just think about all the ways you could pass a thing to a function - references, values, pointers, const references, const pointers, smart pointers, move references, probably more I've forgotten about. Shit, you could just skip the entire function and do it at compile time with templates if you have a spare 20 minutes to compile it and a spare month to learn how the fuck to do it. <|eor|><|eols|><|endoftext|>
12
lolphp
__constructor
cqubek2
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>This is a consequence of PHP not having variable declarations (and every variable having function scope implicitly). Python has half of the same issue because half of its variables (those assigned to) are implicitly scoped to their containing function. Hence `nonlocal` in Python 3, equivalent to PHP's `use`. Most other languages that support closures (Haskell, Perl, JavaScript, ...) have explicit binders / variable declarations, so this is simply not an issue.<|eor|><|sor|>Please don't ever reference JavaScript as the proper way to handle scoping, ever.<|eor|><|eols|><|endoftext|>
7
lolphp
Drainedsoul
cqsda3o
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>Anonymous functions are just like normal functions when it comes to not inheriting variable scope. PHP is actually being consistent here. In PHP, you create a *closure over a scope* by using `use` to selectively pull in variables either at define time or at call time. This isn't lolphp, this is lolatleast*skim*themanual.<|eor|><|sor|>It's inconsistent with every other language I've ever used closures in, though, which I suspect is the point OP was making.<|eor|><|sor|>How about C++?<|eor|><|sor|>In C++ you can use `&` or `=` to capture everything you use. So while it's true that you don't grab the outer function's scope by default, you can do it without typing out every variable you want to capture. <|eor|><|eols|><|endoftext|>
7
lolphp
__constructor
cqubciu
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>Why would you want PHP to implement javascript-style scope pollution? This is how things should be done...<|eor|><|eols|><|endoftext|>
5
lolphp
Synes_Godt_Om
cqrn3dn
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>OP is so wrong on this that it hurts. This is definitely not LOLPHP but LOLnic0nic for not knowing what he/she is talking about. R has exactly the scoping rules OP expects and that is absolutely the last thing anyone could wish for. This particular issue is my biggest gripe with R and one that bites me on a regular basis even after having used the language for more than a decade. I think LOLPHP is dying, which makes sense given the evolution of PHP in recent years.<|eor|><|eols|><|endoftext|>
5
lolphp
barubary
cqrul47
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>This is a consequence of PHP not having variable declarations (and every variable having function scope implicitly). Python has half of the same issue because half of its variables (those assigned to) are implicitly scoped to their containing function. Hence `nonlocal` in Python 3, equivalent to PHP's `use`. Most other languages that support closures (Haskell, Perl, JavaScript, ...) have explicit binders / variable declarations, so this is simply not an issue.<|eor|><|sor|>Well, yes, but also no. Python requires `nonlocal` when you *set* a variable in the outer scope; reading it works fine: def const(x): return lambda _: x That works, and `const(42)(None)` evaluates to `42` as you would expect. PHP differs in that even *reading* the value requires explicitly closing over it. Oh, and yes; let's not forget that PHP closes over *by value*, which is not what you would expect from using closures in Ruby, Python, Javascript, any of the Lisps, et cetera. (Yes, I know how to recover the other semantics. Not the point.)<|eor|><|sor|>That's why I said "half of the same issue". :-)<|eor|><|eols|><|endoftext|>
5
lolphp
barubary
cqus73n
<|sols|><|sot|>It would have been so strange if PHP guys would have implemented a thing "normally" like all others... (x-post from /r/programming)<|eot|><|sol|>http://stackoverflow.com/questions/6543419/php-closure-scope-problem<|eol|><|sor|>This is a consequence of PHP not having variable declarations (and every variable having function scope implicitly). Python has half of the same issue because half of its variables (those assigned to) are implicitly scoped to their containing function. Hence `nonlocal` in Python 3, equivalent to PHP's `use`. Most other languages that support closures (Haskell, Perl, JavaScript, ...) have explicit binders / variable declarations, so this is simply not an issue.<|eor|><|sor|>Please don't ever reference JavaScript as the proper way to handle scoping, ever.<|eor|><|sor|>I didn't; I just think it's better than Python/PHP (explicit scoping > implicit scoping). You can make it "proper" (i.e. like Perl) with this one weird trick discovered by a mom: - Disallow implicit globals (`"use strict";`) - Only use variables with real block scope (`let`)<|eor|><|eols|><|endoftext|>
5
lolphp
Serialk
1i57ve
<|soss|><|sot|>Assignment has a higher precedence than boolean operators<|eot|><|sost|>Well. Yeah. php > $z = false or true; php > var_dump($z); bool(false) php > $z = true and false; php > var_dump($z); bool(true) Actually, "or" and "and" are like "||" and "&&", but with an absurd precedence. Okay.<|eost|><|eoss|><|endoftext|>
22
lolphp
phoshi
cb15gvk
<|soss|><|sot|>Assignment has a higher precedence than boolean operators<|eot|><|sost|>Well. Yeah. php > $z = false or true; php > var_dump($z); bool(false) php > $z = true and false; php > var_dump($z); bool(true) Actually, "or" and "and" are like "||" and "&&", but with an absurd precedence. Okay.<|eost|><|sor|>This does actually have a sane (by PHP's standard) reason for existence, I think. It lets you do `statement_that_can_return_false or failure_handler" regardless of the complexity of your original statement, which does differentiate it from an or with a regular precedence. Why and exists I do not know. Symmetry?<|eor|><|eoss|><|endoftext|>
15
lolphp
Laugarhraun
cb150xg
<|soss|><|sot|>Assignment has a higher precedence than boolean operators<|eot|><|sost|>Well. Yeah. php > $z = false or true; php > var_dump($z); bool(false) php > $z = true and false; php > var_dump($z); bool(true) Actually, "or" and "and" are like "||" and "&&", but with an absurd precedence. Okay.<|eost|><|sor|>Hey OP, if I may, a quicker way to demonstrate this behaviour: php > var_dump($z = false or true); //no surprise bool(true) php > var_dump($z); //wut bool(false)<|eor|><|eoss|><|endoftext|>
12
lolphp
infinull
cb1axfd
<|soss|><|sot|>Assignment has a higher precedence than boolean operators<|eot|><|sost|>Well. Yeah. php > $z = false or true; php > var_dump($z); bool(false) php > $z = true and false; php > var_dump($z); bool(true) Actually, "or" and "and" are like "||" and "&&", but with an absurd precedence. Okay.<|eost|><|sor|>This does actually have a sane (by PHP's standard) reason for existence, I think. It lets you do `statement_that_can_return_false or failure_handler" regardless of the complexity of your original statement, which does differentiate it from an or with a regular precedence. Why and exists I do not know. Symmetry?<|eor|><|sor|>it's a feature borrowed from PERL, if you want "normal" booleans you can use &&, ||, and !, but for these higher precedence ones you use not, and, and or. It flies in the face of the principle of least astonishment, but it does *kind of* make sense.<|eor|><|eoss|><|endoftext|>
12
lolphp
barubary
cb1p9q6
<|soss|><|sot|>Assignment has a higher precedence than boolean operators<|eot|><|sost|>Well. Yeah. php > $z = false or true; php > var_dump($z); bool(false) php > $z = true and false; php > var_dump($z); bool(true) Actually, "or" and "and" are like "||" and "&&", but with an absurd precedence. Okay.<|eost|><|sor|>This does actually have a sane (by PHP's standard) reason for existence, I think. It lets you do `statement_that_can_return_false or failure_handler" regardless of the complexity of your original statement, which does differentiate it from an or with a regular precedence. Why and exists I do not know. Symmetry?<|eor|><|sor|>it's a feature borrowed from PERL, if you want "normal" booleans you can use &&, ||, and !, but for these higher precedence ones you use not, and, and or. It flies in the face of the principle of least astonishment, but it does *kind of* make sense.<|eor|><|sor|>mm, I've seen the perl one used as something like open file, "<file" or die "can't open your stupid file: $!";<|eor|><|sor|>This is spelled open my $fh, "<", $file or die "$0: can't open $file: $!\n"; nowadays (using a local variable instead of a bareword filehandle, 3-arg open instead of 2-arg open). By the way, it's Perl or perl but never PERL. since 2000 (when perl5.6.0 came out)<|eor|><|eoss|><|endoftext|>
10
lolphp
bart2019
cb13qra
<|soss|><|sot|>Assignment has a higher precedence than boolean operators<|eot|><|sost|>Well. Yeah. php > $z = false or true; php > var_dump($z); bool(false) php > $z = true and false; php > var_dump($z); bool(true) Actually, "or" and "and" are like "||" and "&&", but with an absurd precedence. Okay.<|eost|><|sor|>That was likely copied from Perl, where `and` and `or` were exactly introduced because these new introductions could get a lower precedence. They serve to logically chain complete statements with shortcircuiting, much like in the shell: only continue evaluating toward the right as long as the part on the left has the right outcome. The situation is much more absurd in PowerBASIC, a dialect of Basic (from the same developer who originally designed TurboBASIC for Borland) where `AND` could either be boolean `&&` (complete with shortcircuit), or bitwise `&`, depending on, what? The phase of the moon? <|eor|><|eoss|><|endoftext|>
6
lolphp
wefarrell
1fvovs
<|sols|><|sot|>import_request_variables<|eot|><|sol|>http://php.net/manual/en/function.import-request-variables.php<|eol|><|eols|><|endoftext|>
20
lolphp
wefarrell
cae8uhy
<|sols|><|sot|>import_request_variables<|eot|><|sol|>http://php.net/manual/en/function.import-request-variables.php<|eol|><|soopr|>Thankfully this is removed in php 5.4, but the fact that it ever existed really makes you question the sanity of the design.<|eoopr|><|eols|><|endoftext|>
13
lolphp
Rhomboid
caedq1k
<|sols|><|sot|>import_request_variables<|eot|><|sol|>http://php.net/manual/en/function.import-request-variables.php<|eol|><|sor|>`import_request_variables` was added in 4.1.0, and `register_globals` was defaulted to off in 4.2.0. (Both were deprecated in 5.3.0 and removed in 5.4.0.) From that I think we can infer that it was added at the same time the decision was made to turn `register_globals` off by default, as a stopgap measure for being able to support shitty scripts that required `register_globals` without having to rewrite them the proper way. Although if true that logic is impeccably asinine: "this feature is dangerous, we made a mistake, let's at least turn it off by default. Oh and let's provide a new alternative method to continue to be unsafe so that scripts don't have be changed to be actually safe." <|eor|><|eols|><|endoftext|>
11
lolphp
cythrawll
caeczo8
<|sols|><|sot|>import_request_variables<|eot|><|sol|>http://php.net/manual/en/function.import-request-variables.php<|eol|><|soopr|>Thankfully this is removed in php 5.4, but the fact that it ever existed really makes you question the sanity of the design.<|eoopr|><|sor|>Did you forget about register globals?<|eor|><|eols|><|endoftext|>
9
lolphp
arand
z2d0x
<|sols|><|sot|>PHP is a fractal of bad design? Hardly. - Dev Shed forum user says so.<|eot|><|sol|>http://forums.devshed.com/php-development-5/php-is-a-fractal-of-bad-design-hardly-929746.html<|eol|><|eols|><|endoftext|>
23
lolphp
ealf
c636m3k
<|sols|><|sot|>PHP is a fractal of bad design? Hardly. - Dev Shed forum user says so.<|eot|><|sol|>http://forums.devshed.com/php-development-5/php-is-a-fractal-of-bad-design-hardly-929746.html<|eol|><|sor|>Oh wow. Complaint: PHP encourages XSS holes. "Rebuttal": I don't understand how any language could do better.<|eor|><|eols|><|endoftext|>
17
lolphp
Legolas-the-elf
c6oqwg8
<|sols|><|sot|>PHP is a fractal of bad design? Hardly. - Dev Shed forum user says so.<|eot|><|sol|>http://forums.devshed.com/php-development-5/php-is-a-fractal-of-bad-design-hardly-929746.html<|eol|><|sor|>Sometimes I wish online forums had the age and experience level of the people involved prominently displayed. I make the same mistake he does, I assume I'm talking to somebody who might be wrong about a few things, but is at least in the same ball-park as a competent professional. Sometimes I end up in arguments like that and a few replies in, I realise I'm probably talking to a kid or somebody who's just started in the industry who is operating under a huge veil of ignorance but thinks they know everything.<|eor|><|eols|><|endoftext|>
8
lolphp
robin-gvx
c6ao3js
<|sols|><|sot|>PHP is a fractal of bad design? Hardly. - Dev Shed forum user says so.<|eot|><|sol|>http://forums.devshed.com/php-development-5/php-is-a-fractal-of-bad-design-hardly-929746.html<|eol|><|sor|>Oh my god, that's terrible. And it gets worse when that user starts replying to the Fractal author's rebuttal of the rebuttal. Oddly fascinating to read, but then that's what this subreddit's for, isn't it?<|eor|><|eols|><|endoftext|>
7
lolphp
nemoTheKid
c65lxkb
<|sols|><|sot|>PHP is a fractal of bad design? Hardly. - Dev Shed forum user says so.<|eot|><|sol|>http://forums.devshed.com/php-development-5/php-is-a-fractal-of-bad-design-hardly-929746.html<|eol|><|sor|>I was surprised when I saw this was written last week. The guy hes arguing with is either 15 or a troll. Hes wasting his time.<|eor|><|eols|><|endoftext|>
6
lolphp
sumdog
c6jneye
<|sols|><|sot|>PHP is a fractal of bad design? Hardly. - Dev Shed forum user says so.<|eot|><|sol|>http://forums.devshed.com/php-development-5/php-is-a-fractal-of-bad-design-hardly-929746.html<|eol|><|sor|>"OMG you critized the only language I have ever seen!!!!!!!" > Does Python have some magical way of changing the way the webserver accesses files? LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL. > Your argument here is that programming languages are meant for humans? Not computers? Honestly? ROFL. > honestly I don't care if the return value is "", 0, null, or false. You can't make this shit up. > You seem to think I and my friends are stupid. You're sorely mistaken. O RLY?<|eor|><|sor|>> Just look at his list of "surprises": mysql_real_escape_string? OH MY GOD! SHOCKING! What the hell is he talking about? (O_o)<|eor|><|eols|><|endoftext|>
6
lolphp
robin-gvx
c6ao5k1
<|sols|><|sot|>PHP is a fractal of bad design? Hardly. - Dev Shed forum user says so.<|eot|><|sol|>http://forums.devshed.com/php-development-5/php-is-a-fractal-of-bad-design-hardly-929746.html<|eol|><|sor|>Oh my god, that's terrible. And it gets worse when that user starts replying to the Fractal author's rebuttal of the rebuttal. Oddly fascinating to read, but then that's what this subreddit's for, isn't it?<|eor|><|sor|>The worst part is that they get so terribly _offended_ because of something that isn't offensive and then keep digging themselves in deeper by their lack of understanding of PHP, other programming languages, operating systems, servers, file systems, argumentation, ...<|eor|><|eols|><|endoftext|>
6
lolphp
vytah
vfysj
<|sols|><|sot|>basename() strips non-ASCII characters from beginning of a filename <|eot|><|sol|>https://bugs.php.net/bug.php?id=62119<|eol|><|eols|><|endoftext|>
22
lolphp
Rhomboid
c54a2ql
<|sols|><|sot|>basename() strips non-ASCII characters from beginning of a filename <|eot|><|sol|>https://bugs.php.net/bug.php?id=62119<|eol|><|sor|>PHP's behavior is clearly strange and inconsistent, but trying to use strings that contain non-ASCII characters when your locale is "C" is also nutso. "C" locale means "I will only be using ASCII", so whatever the reporter was trying to achieve is probably a recipe for failure. Although someone will probably come along and tell me that PHP programmers routinely leave the locale set to "C" and expect to be able to use ISO-8859-1 or CP1252 or UTF-8 encoded strings, at which point I will just bang my head on the table. Perhaps the fact that PHP exposes the antiquated and rickety locale system inherited from C is the real wtf here. <|eor|><|eols|><|endoftext|>
12
lolphp
audaxxx
c54adyz
<|sols|><|sot|>basename() strips non-ASCII characters from beginning of a filename <|eot|><|sol|>https://bugs.php.net/bug.php?id=62119<|eol|><|sor|>PHP's behavior is clearly strange and inconsistent, but trying to use strings that contain non-ASCII characters when your locale is "C" is also nutso. "C" locale means "I will only be using ASCII", so whatever the reporter was trying to achieve is probably a recipe for failure. Although someone will probably come along and tell me that PHP programmers routinely leave the locale set to "C" and expect to be able to use ISO-8859-1 or CP1252 or UTF-8 encoded strings, at which point I will just bang my head on the table. Perhaps the fact that PHP exposes the antiquated and rickety locale system inherited from C is the real wtf here. <|eor|><|sor|>I am just irritated that PHP always silently fails with weird results. There are so many ways you can break PHP and most times it will not fail with a loud error but just produce weird results.<|eor|><|eols|><|endoftext|>
9
lolphp
audaxxx
c549j35
<|sols|><|sot|>basename() strips non-ASCII characters from beginning of a filename <|eot|><|sol|>https://bugs.php.net/bug.php?id=62119<|eol|><|sor|>Now I want to see the explanation why this behaviour is correct and the programmer is just stupid. I am sure, Rasmus will deliver.<|eor|><|eols|><|endoftext|>
8
lolphp
infinull
c54dxxd
<|sols|><|sot|>basename() strips non-ASCII characters from beginning of a filename <|eot|><|sol|>https://bugs.php.net/bug.php?id=62119<|eol|><|sor|>Weird behavior, but why would anyone ever name a file like that? I would always strip those kind of characters, or replace them with the standard "a". Edit: FYI, I'm referring to class name files, not just standard files.<|eor|><|sor|>Foreign Languages, also why should we not have unicode everywhere?<|eor|><|eols|><|endoftext|>
5
lolphp
Takeoded
r2m35d
<|sols|><|sot|>comments "on Function Overloading Feature"<|eot|><|sol|>https://www.php.net/manual/en/mbstring.overload.php<|eol|><|eols|><|endoftext|>
20
lolphp
sproingie
hm5lift
<|sols|><|sot|>comments "on Function Overloading Feature"<|eot|><|sol|>https://www.php.net/manual/en/mbstring.overload.php<|eol|><|sor|>That very last comment ... shudder. TIL PHP has a multibyte-by-default setting. It looks like it doesn't give you any way to get back to byte-wise operations when you need them tho. I'm a little surprised it didn't get axed in 8.0, but maybe everyone just forgot about it.<|eor|><|eols|><|endoftext|>
10
lolphp
Takeoded
hm5mifj
<|sols|><|sot|>comments "on Function Overloading Feature"<|eot|><|sol|>https://www.php.net/manual/en/mbstring.overload.php<|eol|><|sor|>That very last comment ... shudder. TIL PHP has a multibyte-by-default setting. It looks like it doesn't give you any way to get back to byte-wise operations when you need them tho. I'm a little surprised it didn't get axed in 8.0, but maybe everyone just forgot about it.<|eor|><|soopr|>>I'm a little surprised it didn't get axed in 8.0 no it did! deprecated as of php7.2.0 and completely removed in 8.0.0 >It looks like it doesn't give you any way to get back to byte-wise operations when you need them tho i recall seeing code like `$len=mb_strlen($str,'ASCII');` because they needed to know how many bytes were in a string in a codebase using this overloading deathtrap<|eoopr|><|eols|><|endoftext|>
8
lolphp
Takeoded
hm5ucxf
<|sols|><|sot|>comments "on Function Overloading Feature"<|eot|><|sol|>https://www.php.net/manual/en/mbstring.overload.php<|eol|><|sor|>That very last comment ... shudder. TIL PHP has a multibyte-by-default setting. It looks like it doesn't give you any way to get back to byte-wise operations when you need them tho. I'm a little surprised it didn't get axed in 8.0, but maybe everyone just forgot about it.<|eor|><|soopr|>>I'm a little surprised it didn't get axed in 8.0 no it did! deprecated as of php7.2.0 and completely removed in 8.0.0 >It looks like it doesn't give you any way to get back to byte-wise operations when you need them tho i recall seeing code like `$len=mb_strlen($str,'ASCII');` because they needed to know how many bytes were in a string in a codebase using this overloading deathtrap<|eoopr|><|sor|>Ah, good to know its gone. Im not sure its that disastrous given that modern Perl idiom has been everything-as-utf8 for a while. But it also validates I/O at the edge and this overloading (really overriding) does not, and thats an important difference. Same deal with python.<|eor|><|soopr|>fwiw when you made the comment, it wasn't documented that 8.0.0 removed it on the linked-to-page, thanks for making that obvious, just fixed it, https://github.com/php/doc-en/pull/1149<|eoopr|><|eols|><|endoftext|>
8
lolphp
chengannur
mbi1qw
<|sols|><|sot|>Another one of those epic discussions.<|eot|><|sol|>https://externals.io/message/113645<|eol|><|eols|><|endoftext|>
22
lolphp
elcapitanoooo
gry06p1
<|sols|><|sot|>Another one of those epic discussions.<|eot|><|sol|>https://externals.io/message/113645<|eol|><|sor|>Damn. Looks like they wont even try to have builtin unicode support. How about deprecate ALL the builtin oddities (iconv, mb_functions etc etc) and remove them in PHP9 and introduce real builtin unicode for everything.<|eor|><|eols|><|endoftext|>
15
lolphp
duskwuff
grztwt9
<|sols|><|sot|>Another one of those epic discussions.<|eot|><|sol|>https://externals.io/message/113645<|eol|><|sor|>Damn. Looks like they wont even try to have builtin unicode support. How about deprecate ALL the builtin oddities (iconv, mb_functions etc etc) and remove them in PHP9 and introduce real builtin unicode for everything.<|eor|><|sor|>> Damn. Looks like they wont even try to have builtin unicode support. Do you know what `utf8_encode()` and `utf8_decode()` even do? (Hint: it's neither required nor useful in implementing "Unicode support".)<|eor|><|eols|><|endoftext|>
11
lolphp
Muzer0
gs1vhft
<|sols|><|sot|>Another one of those epic discussions.<|eot|><|sol|>https://externals.io/message/113645<|eol|><|sor|>Damn. Looks like they wont even try to have builtin unicode support. How about deprecate ALL the builtin oddities (iconv, mb_functions etc etc) and remove them in PHP9 and introduce real builtin unicode for everything.<|eor|><|sor|>This might be an unpopular opinion but IMHO there are only two ways to correctly handle "unicode support": * Make it very comprehensive as a language built-in feature that does everything correctly, is aware of glyphs, performs normalisation, etc. (Swift) * Make it very clear your strings are just strings of bytes and if you want any Unicode support you'll have to use a library (C) Anything apart from these two methods is fraught with difficulty and error-prone. You effectively get the worst of both worlds - poor performance when iterating through strings, and potentially incorrect behaviour when attempting to do transformations on a character level. Take Python for instance - it has "unicode support" in the sense that it is aware of code points within a string, but without using a library you can't normalise strings, which means you can't correctly compare them; and it has no concept of glyphs, so you can't slice them. You also can't tell their length in any meaningful way; number of code points is not something that is meaningful to anyone. So what are we left with? Some overcomplicated language feature that benefits... people who write Unicode libraries. That's pretty much it. But it does make a lot of people think "oh, Python supports unicode, so I don't have to worry", so they're going to do all these things that Python isn't handling correctly and then wonder why their code breaks when you pass in an emoji.<|eor|><|eols|><|endoftext|>
9
lolphp
svtguy88
gs0eed1
<|sols|><|sot|>Another one of those epic discussions.<|eot|><|sol|>https://externals.io/message/113645<|eol|><|sor|>Why on earth do people still use and defend this so called language<|eor|><|sor|>Because market share... People will defend whatever language is making them a living.<|eor|><|eols|><|endoftext|>
9
lolphp
SockPants
grywefz
<|sols|><|sot|>Another one of those epic discussions.<|eot|><|sol|>https://externals.io/message/113645<|eol|><|sor|>Damn. Looks like they wont even try to have builtin unicode support. How about deprecate ALL the builtin oddities (iconv, mb_functions etc etc) and remove them in PHP9 and introduce real builtin unicode for everything.<|eor|><|sor|>Create a merge request for it.<|eor|><|sor|>Yeah sure gimme a sec lol<|eor|><|eols|><|endoftext|>
7
lolphp
ocurero
gryfgju
<|sols|><|sot|>Another one of those epic discussions.<|eot|><|sol|>https://externals.io/message/113645<|eol|><|sor|>PHP in a nutshell.<|eor|><|eols|><|endoftext|>
6
lolphp
SaltineAmerican_1970
grylk6w
<|sols|><|sot|>Another one of those epic discussions.<|eot|><|sol|>https://externals.io/message/113645<|eol|><|sor|>Damn. Looks like they wont even try to have builtin unicode support. How about deprecate ALL the builtin oddities (iconv, mb_functions etc etc) and remove them in PHP9 and introduce real builtin unicode for everything.<|eor|><|sor|>Create a merge request for it.<|eor|><|eols|><|endoftext|>
6
lolphp
Mark_Messa
dm4244
<|soss|><|sot|>PHP Functions: more arguments than expected<|eot|><|sost|>PHP code1: function f() {return 'hello world!';} echo f().'<br>'; echo f(123).'<br>'; echo f(123, 'foo').'<br>'; Output: hello world! hello world! hello world! &nbsp; PHP code2: function g(int $x) {return 'hello world!';} echo g(123).'<br>'; echo g(123, 'foo').'<br>'; Output: hello world! hello world! &nbsp; **Question** Is it possible to force PHP to throw an error when passing more arguments than the function expects? &nbsp; *** **Follow-up** There was already a RFC proposing a [Strict Argument Count On Function Calls](https://wiki.php.net/rfc/strict_argcount) which, unfortunately, was withdraw due to high rejection. Some interesting points available in it are: - "During the tests it became clearly measurable that the proposed strict argument count check won't be an issue. Actually, it's quite the opposite. It will help to increase PHP code quality from PHP7 and forward as all warnings were useful to catch mistakes or even bugs." - "The RFC was withdraw due to many controversial points and overall rejection and won't be proposed again by the RFC author. The RFC author advises to not revive this RFC as it was already rejected." A deeper discussion is also available: [\[PHP-DEV\]\[RFC\]\[DISCUSSION\] Strict Argument Count](https://marc.info/?t=142525116400001&r=1&w=2)<|eost|><|eoss|><|endoftext|>
19
lolphp
blipblop_
f4wpamb
<|soss|><|sot|>PHP Functions: more arguments than expected<|eot|><|sost|>PHP code1: function f() {return 'hello world!';} echo f().'<br>'; echo f(123).'<br>'; echo f(123, 'foo').'<br>'; Output: hello world! hello world! hello world! &nbsp; PHP code2: function g(int $x) {return 'hello world!';} echo g(123).'<br>'; echo g(123, 'foo').'<br>'; Output: hello world! hello world! &nbsp; **Question** Is it possible to force PHP to throw an error when passing more arguments than the function expects? &nbsp; *** **Follow-up** There was already a RFC proposing a [Strict Argument Count On Function Calls](https://wiki.php.net/rfc/strict_argcount) which, unfortunately, was withdraw due to high rejection. Some interesting points available in it are: - "During the tests it became clearly measurable that the proposed strict argument count check won't be an issue. Actually, it's quite the opposite. It will help to increase PHP code quality from PHP7 and forward as all warnings were useful to catch mistakes or even bugs." - "The RFC was withdraw due to many controversial points and overall rejection and won't be proposed again by the RFC author. The RFC author advises to not revive this RFC as it was already rejected." A deeper discussion is also available: [\[PHP-DEV\]\[RFC\]\[DISCUSSION\] Strict Argument Count](https://marc.info/?t=142525116400001&r=1&w=2)<|eost|><|sor|>>Is it possible to force PHP to throw an error when passing more arguments than the function expects? No. PHP 7.1 and above throws and error on too few arguments though. Earlier versions displays a warning. Too many arguments is a language feature and wont be fixed (silly as it is). https://bugs.php.net/bug.php?id=13892<|eor|><|eoss|><|endoftext|>
13
lolphp
Mark_Messa
f4wxeup
<|soss|><|sot|>PHP Functions: more arguments than expected<|eot|><|sost|>PHP code1: function f() {return 'hello world!';} echo f().'<br>'; echo f(123).'<br>'; echo f(123, 'foo').'<br>'; Output: hello world! hello world! hello world! &nbsp; PHP code2: function g(int $x) {return 'hello world!';} echo g(123).'<br>'; echo g(123, 'foo').'<br>'; Output: hello world! hello world! &nbsp; **Question** Is it possible to force PHP to throw an error when passing more arguments than the function expects? &nbsp; *** **Follow-up** There was already a RFC proposing a [Strict Argument Count On Function Calls](https://wiki.php.net/rfc/strict_argcount) which, unfortunately, was withdraw due to high rejection. Some interesting points available in it are: - "During the tests it became clearly measurable that the proposed strict argument count check won't be an issue. Actually, it's quite the opposite. It will help to increase PHP code quality from PHP7 and forward as all warnings were useful to catch mistakes or even bugs." - "The RFC was withdraw due to many controversial points and overall rejection and won't be proposed again by the RFC author. The RFC author advises to not revive this RFC as it was already rejected." A deeper discussion is also available: [\[PHP-DEV\]\[RFC\]\[DISCUSSION\] Strict Argument Count](https://marc.info/?t=142525116400001&r=1&w=2)<|eost|><|sor|>>Is it possible to force PHP to throw an error when passing more arguments than the function expects? No. PHP 7.1 and above throws and error on too few arguments though. Earlier versions displays a warning. Too many arguments is a language feature and wont be fixed (silly as it is). https://bugs.php.net/bug.php?id=13892<|eor|><|sor|>I love their replies. "LOL IT DOESN'T AFFECT THE PROGRAM SO JUST LET IT GO"<|eor|><|soopr|>> And what's wrong with specifying too many parameters? If you don't use them explicitly, they don't influence the function, so why care about them? > _sander@php.net_ @firechill2004 I would like to have the same sense of humor as you have ...<|eoopr|><|eoss|><|endoftext|>
8
lolphp
Mark_Messa
f4y8rln
<|soss|><|sot|>PHP Functions: more arguments than expected<|eot|><|sost|>PHP code1: function f() {return 'hello world!';} echo f().'<br>'; echo f(123).'<br>'; echo f(123, 'foo').'<br>'; Output: hello world! hello world! hello world! &nbsp; PHP code2: function g(int $x) {return 'hello world!';} echo g(123).'<br>'; echo g(123, 'foo').'<br>'; Output: hello world! hello world! &nbsp; **Question** Is it possible to force PHP to throw an error when passing more arguments than the function expects? &nbsp; *** **Follow-up** There was already a RFC proposing a [Strict Argument Count On Function Calls](https://wiki.php.net/rfc/strict_argcount) which, unfortunately, was withdraw due to high rejection. Some interesting points available in it are: - "During the tests it became clearly measurable that the proposed strict argument count check won't be an issue. Actually, it's quite the opposite. It will help to increase PHP code quality from PHP7 and forward as all warnings were useful to catch mistakes or even bugs." - "The RFC was withdraw due to many controversial points and overall rejection and won't be proposed again by the RFC author. The RFC author advises to not revive this RFC as it was already rejected." A deeper discussion is also available: [\[PHP-DEV\]\[RFC\]\[DISCUSSION\] Strict Argument Count](https://marc.info/?t=142525116400001&r=1&w=2)<|eost|><|sor|>>Is it possible to force PHP to throw an error when passing more arguments than the function expects? No. PHP 7.1 and above throws and error on too few arguments though. Earlier versions displays a warning. Too many arguments is a language feature and wont be fixed (silly as it is). https://bugs.php.net/bug.php?id=13892<|eor|><|sor|>I love their replies. "LOL IT DOESN'T AFFECT THE PROGRAM SO JUST LET IT GO"<|eor|><|soopr|>> IT DOESN'T AFFECT THE PROGRAM SO JUST LET IT GO I keep on thinking on your comment. The same could be said about **type hinting:** "it doesn't affect the program, so just let it go!"<|eoopr|><|eoss|><|endoftext|>
7
lolphp
Mark_Messa
f4xhlex
<|soss|><|sot|>PHP Functions: more arguments than expected<|eot|><|sost|>PHP code1: function f() {return 'hello world!';} echo f().'<br>'; echo f(123).'<br>'; echo f(123, 'foo').'<br>'; Output: hello world! hello world! hello world! &nbsp; PHP code2: function g(int $x) {return 'hello world!';} echo g(123).'<br>'; echo g(123, 'foo').'<br>'; Output: hello world! hello world! &nbsp; **Question** Is it possible to force PHP to throw an error when passing more arguments than the function expects? &nbsp; *** **Follow-up** There was already a RFC proposing a [Strict Argument Count On Function Calls](https://wiki.php.net/rfc/strict_argcount) which, unfortunately, was withdraw due to high rejection. Some interesting points available in it are: - "During the tests it became clearly measurable that the proposed strict argument count check won't be an issue. Actually, it's quite the opposite. It will help to increase PHP code quality from PHP7 and forward as all warnings were useful to catch mistakes or even bugs." - "The RFC was withdraw due to many controversial points and overall rejection and won't be proposed again by the RFC author. The RFC author advises to not revive this RFC as it was already rejected." A deeper discussion is also available: [\[PHP-DEV\]\[RFC\]\[DISCUSSION\] Strict Argument Count](https://marc.info/?t=142525116400001&r=1&w=2)<|eost|><|sor|>PHP7 could have fixed this. But nothing was done.<|eor|><|soopr|>Considering that this bug report was mainly discussed over 2001, I guess that even PHP5 could have this already fixed.<|eoopr|><|eoss|><|endoftext|>
6