subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
steamruler
cu2mrf2
<|sols|><|sot|>This should *never* happen!<|eot|><|sol|>http://i.imgur.com/Y9Mi8QX.png<|eol|><|sor|>"Should not" doesn't mean "can't". Your TZ database shouldn't be corrupted, because then shit is seriously wrong. It's a bit of a "this is a graver exception than other exceptions" <|eor|><|eols|><|endoftext|>
44
lolphp
qxxx
cu2qpa7
<|sols|><|sot|>This should *never* happen!<|eot|><|sol|>http://i.imgur.com/Y9Mi8QX.png<|eol|><|sor|>I wonder how much they paid to the Timezone... damn corruption.<|eor|><|eols|><|endoftext|>
15
lolphp
HildartheDorf
cu3pdvz
<|sols|><|sot|>This should *never* happen!<|eot|><|sol|>http://i.imgur.com/Y9Mi8QX.png<|eol|><|sor|>"Should not" doesn't mean "can't". Your TZ database shouldn't be corrupted, because then shit is seriously wrong. It's a bit of a "this is a graver exception than other exceptions" <|eor|><|sor|>I add the "should not happen" kind of logging messages to programs when it's a non fatal error if some chain of conditionals doesn't catch what it's supposed to. I would probably use a different formatting but that maybe standard php error formatting, I'm not familiar with that.<|eor|><|sor|>"Should not happen" is for things that would be assert() fails, but you can't have it go and call abort(). This is a prime example, the system is totally and utterly screwed (the user went and manually scrambled the database? Cosmic ray hit the ram?), but it's PHP so it will soldier on and break more things rather than panicking...<|eor|><|eols|><|endoftext|>
12
lolphp
thomasfr
cu5vo7b
<|sols|><|sot|>This should *never* happen!<|eot|><|sol|>http://i.imgur.com/Y9Mi8QX.png<|eol|><|sor|>You are right, PHP should never have happened.<|eor|><|sor|>I'm not sure why people are downvoting you, I couldn't agree more<|eor|><|sor|>I guess one answer is because it really doesn't matter, PHP will be there regardless if we want it to or not. Btw, this sub should allow for both up and down voting simultaneously to get in line with the PHP design spirit :)<|eor|><|eols|><|endoftext|>
11
lolphp
thomasfr
cu2owjr
<|sols|><|sot|>This should *never* happen!<|eot|><|sol|>http://i.imgur.com/Y9Mi8QX.png<|eol|><|sor|>"Should not" doesn't mean "can't". Your TZ database shouldn't be corrupted, because then shit is seriously wrong. It's a bit of a "this is a graver exception than other exceptions" <|eor|><|sor|>I add the "should not happen" kind of logging messages to programs when it's a non fatal error if some chain of conditionals doesn't catch what it's supposed to. I would probably use a different formatting but that maybe standard php error formatting, I'm not familiar with that.<|eor|><|eols|><|endoftext|>
5
lolphp
fragglet
2h1s52
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|eols|><|endoftext|>
132
lolphp
appointment_at_1_am
ckoloao
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Seriously that should be taken down. Somebody will use this and innocent people will take the fall.<|eor|><|eols|><|endoftext|>
60
lolphp
duskwuff
ckolung
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>My, my, my. SQL injection *and* improper credit card storage, all in one place. Also, from the comments: > You must do security for Home Depot. Ooh, *burn.*<|eor|><|eols|><|endoftext|>
58
lolphp
Sebbe
ckolqz3
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Can't blame PHP for that one, so it's not really a true lolphp.<|eor|><|eols|><|endoftext|>
40
lolphp
urquan
ckop2pj
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Got to love the generic instructions too : How to build a website: 1. Use notepad to write the code for the website 2. Click File > Save to put the code in a file 3. ? 4. Profit!<|eor|><|eols|><|endoftext|>
23
lolphp
skeeto
ckordlo
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>eHow is a joke. <|eor|><|sor|>Following the heritage of ExpertsExchange, eHow is the latest awful content farm to blight so many search results. So incredibly annoying. Here's another gem from the other day: [TIL To multiply in C you need while loops](https://www.reddit.com/r/coding/comments/2gvcvy/til_to_multiply_in_c_you_need_while_loops/) <|eor|><|eols|><|endoftext|>
22
lolphp
Golden_Calf
ckoubnh
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Can't blame PHP for that one, so it's not really a true lolphp.<|eor|><|sor|>Honestly a good chunk of the content on here isn't necessarily an issue with PHP but what people do with it as there are a ton of people with no experience using it. If the whole sub was just rehashing the same language issues then it would simply die without new content. <|eor|><|eols|><|endoftext|>
19
lolphp
cjwelborn
ckooauj
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>eHow is a joke. <|eor|><|sor|>Second article I've seen like this in a day (eHow, with really bad/joke advice) . Do people actually use this site for programming advice. I hope not.<|eor|><|eols|><|endoftext|>
13
lolphp
dochoncho
ckpdgl8
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Seriously that should be taken down. Somebody will use this and innocent people will take the fall.<|eor|><|sor|>IKR? They should at least be advocating applying ROT13 at least once to the output of the base 64 encoding function. This is just begging for people to get hurt by weak encryption practices! Encrypted: ZGNlAPNlZQD4VQDjBGLtBQR5Zt== Bad Encrypted: MTAyNCAyMDQ4IDQwOTYgODE5Mg== >> b64decode(b'ZGNlAPNlZQD4VQDjBGLtBQR5Zt==') Traceback (most recent call last): File "encrypt.py", line 21, in <module> print(b64decode(encrypted_cc)) File "encrypt.py", line 8, in b64decode return base64.b64decode(bytes(data, 'utf-8')).decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 4: invalid continuation byte Thwarted! They'll never figure out why the encrypted one isn't utf-8 data! I'm in the process of bootstrapping a start up to commercialize this technology. VC's, call me!<|eor|><|eols|><|endoftext|>
12
lolphp
cjwelborn
ckonx0c
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Try stealing my credit card number now, suckers! NDY1MyAyMDE5IDUwNzIgNDA2Mw== [Relevant](https://twitter.com/NeedADebitCard)<|eor|><|sor|>All your card are belong to us: `4653 2019 5072 4063`<|eor|><|eols|><|endoftext|>
12
lolphp
graingert
ckokpz3
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Wow. That's really stupid.<|eor|><|eols|><|endoftext|>
11
lolphp
KFCConspiracy
ckpaxia
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Seriously that should be taken down. Somebody will use this and innocent people will take the fall.<|eor|><|sor|>[deleted]<|eor|><|sor|>Seriously? Huge PCI compliance risk. Part of our PCI compliance report includes information about encryption algorithms and key size (We a third party for tokenization, but were directed by our consultants to state that and that we're out of scope, but to also include a statement about how the third party stores that data). Edit: (Sorry misread the password part as credit card numbers) <|eor|><|eols|><|endoftext|>
11
lolphp
LinkXXI
ckor2ht
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Try stealing my credit card number now, suckers! NDY1MyAyMDE5IDUwNzIgNDA2Mw== [Relevant](https://twitter.com/NeedADebitCard)<|eor|><|sor|>But.... You need the code on the back too...<|eor|><|sor|>Its ok, just upload a picture of each side!<|eor|><|eols|><|endoftext|>
11
lolphp
DoctorWaluigiTime
ckoz3nx
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Can't blame PHP for that one, so it's not really a true lolphp.<|eor|><|sor|>Honestly a good chunk of the content on here isn't necessarily an issue with PHP but what people do with it as there are a ton of people with no experience using it. If the whole sub was just rehashing the same language issues then it would simply die without new content. <|eor|><|sor|>While in this case I agree, there are some instances where the language makes it so easy to shoot yourself in the foot that it is a lolphp. There defeinitely is a good chunk of "bad programmer" posts here though, things that not even a great language could prevent.<|eor|><|eols|><|endoftext|>
9
lolphp
disclosure5
ckt4eg0
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Seriously that should be taken down. Somebody will use this and innocent people will take the fall.<|eor|><|sor|>[deleted]<|eor|><|sor|>Seriously? Huge PCI compliance risk. Part of our PCI compliance report includes information about encryption algorithms and key size (We a third party for tokenization, but were directed by our consultants to state that and that we're out of scope, but to also include a statement about how the third party stores that data). Edit: (Sorry misread the password part as credit card numbers) <|eor|><|sor|>[deleted]<|eor|><|sor|>You guys are required to file statements about your compliance and undergo auditing right? :P You can't possibly be handling very many transactions if not. <|eor|><|sor|>I'm not him but.. yes, I'm required to answer a checklist for a person who will agree that Base64 is military grade encryption if I call it that.<|eor|><|eols|><|endoftext|>
7
lolphp
disclosure5
ckt4qv7
<|sols|><|sot|>How to store credit card numbers securely: "Programming languages such as PHP have built in functions that can encrypt. An example is the base 64 encryption function"<|eot|><|sol|>https://www.ehow.com/how_7450803_encrypt-card-information-sql-database.html<|eol|><|sor|>Seriously that should be taken down. Somebody will use this and innocent people will take the fall.<|eor|><|sor|>[deleted]<|eor|><|sor|>Seriously? Huge PCI compliance risk. Part of our PCI compliance report includes information about encryption algorithms and key size (We a third party for tokenization, but were directed by our consultants to state that and that we're out of scope, but to also include a statement about how the third party stores that data). Edit: (Sorry misread the password part as credit card numbers) <|eor|><|sor|>[deleted]<|eor|><|sor|>You guys are required to file statements about your compliance and undergo auditing right? :P You can't possibly be handling very many transactions if not. <|eor|><|sor|>I'm not him but.. yes, I'm required to answer a checklist for a person who will agree that Base64 is military grade encryption if I call it that.<|eor|><|sor|>Yeah, our third party auditing company asks us questions about how many bits are keys are, what ciphers we're using and shit like that... And although PCI says "Strong cryptography" with no definition, it's made clear that certain ciphers are preferable. It's kind of disturbing how bad your auditing company is. Who are they? I want to avoid them like the plague... <|eor|><|sor|>I don't want to name anyone but let's look at some of the complaints they've raised. Each of these required a plan to address them within a short timeframe before they would pass the "security" audit. * No electrical test + tag on some servers * No asset tag on some CAT5 cables * Inconsistent server naming conventions<|eor|><|eols|><|endoftext|>
7
lolphp
MoederPoeder
1ssdla
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|eols|><|endoftext|>
128
lolphp
Innominate8
ce0u0ca
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>better idea to not clutter up the language: make rand take an extra optional argument, defining the type of random operation that it should run.<|eor|><|sor|>int rand ( int $min , int $max, bool $actually_random = false )<|eor|><|eols|><|endoftext|>
48
lolphp
Innominate8
ce0ubve
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>better idea to not clutter up the language: make rand take an extra optional argument, defining the type of random operation that it should run.<|eor|><|sor|>int rand ( int $min , int $max, bool $actually_random = false )<|eor|><|sor|>Exactly, though I might go for an enum or something for futureproofness<|eor|><|sor|>nah, if it needs to be changed in the future we can just keep going: int rand ( int $min , int $max, bool $actually_random = false, bool $and_this_time_i_mean_it = false )<|eor|><|eols|><|endoftext|>
38
lolphp
morphotomy
ce0tsqf
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Also, mt_rand uses a mersenne twister, which isn't cryptographically secure, so depending on use case, you might need an even better one.<|eor|><|soopr|>Time for a better better random value generator!<|eoopr|><|sor|> randomer(); more_randomer(); more_mt_randomer(); mt_more_betterRandomer();<|eor|><|eols|><|endoftext|>
36
lolphp
ajmarks
ce0qs5w
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Because rand() is included for historical reasons (PHP doesn't know how to let bad things die), but mt_rand() is consistent across systems. Also, see this discussion http://www.reddit.com/r/lolphp/comments/1pvf3h/phps_mt_rand_random_number_generating_function/ .<|eor|><|eols|><|endoftext|>
32
lolphp
kageurufu
ce11hug
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Also, mt_rand uses a mersenne twister, which isn't cryptographically secure, so depending on use case, you might need an even better one.<|eor|><|soopr|>Time for a better better random value generator!<|eoopr|><|sor|> randomer(); more_randomer(); more_mt_randomer(); mt_more_betterRandomer();<|eor|><|sor|>rand_mt_better($min, $max); rand_best_mt($max, $min); new_rand_mt_best($min, $step, $max); more php in there<|eor|><|eols|><|endoftext|>
23
lolphp
postmodest
ce1324c
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>better idea to not clutter up the language: make rand take an extra optional argument, defining the type of random operation that it should run.<|eor|><|sor|>int rand ( int $min , int $max, bool $actually_random = false )<|eor|><|sor|>Exactly, though I might go for an enum or something for futureproofness<|eor|><|sor|>No, no, the most-PHP way would be to make it int rand ( int $min , int $max, bool $actually_random = false ) [v. 5.7.0] int rand ( int $min , int $max, int DEFAULT_RAND <see RAND_MODES for types> ) [v. 5.7.3]<|eor|><|eols|><|endoftext|>
23
lolphp
Rhomboid
ce17iot
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Also, mt_rand uses a mersenne twister, which isn't cryptographically secure, so depending on use case, you might need an even better one.<|eor|><|sor|>For some reason people think it's good just because it has a very long period (2^19937 - 1)<|eor|><|sor|>MT is useful in simulation since it is long period. Not a lot of simulation software written in PHP, however.<|eor|><|sor|>You don't need that long a period. Something like 2^128 would be more than enough (see crypto)<|eor|><|sor|>Not necessarily. For example, a simple deck of 52 cards has 52! possible outcomes when shuffled. That's &asymp;2^(226), and so if your PRNG doesn't have a period of at least that long, it won't be able to properly shuffle a deck of cards, because there will exist some potential decks that can never be selected, by the pigeonhole principle. That's why MT is a popular choice. <|eor|><|eols|><|endoftext|>
23
lolphp
Conradfr
ce0queb
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Also, mt_rand uses a mersenne twister, which isn't cryptographically secure, so depending on use case, you might need an even better one.<|eor|><|sor|>As advised on the documentation.<|eor|><|eols|><|endoftext|>
22
lolphp
MoederPoeder
ce0qu57
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Also, mt_rand uses a mersenne twister, which isn't cryptographically secure, so depending on use case, you might need an even better one.<|eor|><|soopr|>Time for a better better random value generator!<|eoopr|><|eols|><|endoftext|>
17
lolphp
voetsjoeba
ce12ezg
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Also, mt_rand uses a mersenne twister, which isn't cryptographically secure, so depending on use case, you might need an even better one.<|eor|><|soopr|>Time for a better better random value generator!<|eoopr|><|sor|> randomer(); more_randomer(); more_mt_randomer(); mt_more_betterRandomer();<|eor|><|sor|>real_rand();<|eor|><|eols|><|endoftext|>
17
lolphp
MoederPoeder
ce0qtdo
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Because rand() is included for historical reasons (PHP doesn't know how to let bad things die), but mt_rand() is consistent across systems. Also, see this discussion http://www.reddit.com/r/lolphp/comments/1pvf3h/phps_mt_rand_random_number_generating_function/ .<|eor|><|soopr|>But, even though that's great and all, most users will use rand() and not look any further, not knowing that it in fact, isn't that random. 'Historical reasons' seem to be most of the reasons of php's flaws. Also I knew this was gonna be posted already on here but it was mostly the docs that made me laugh, not specifically the fact that rand() sucks.<|eoopr|><|eols|><|endoftext|>
13
lolphp
AyeGill
ce0sysh
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Also, mt_rand uses a mersenne twister, which isn't cryptographically secure, so depending on use case, you might need an even better one.<|eor|><|sor|>For some reason people think it's good just because it has a very long period (2^19937 - 1)<|eor|><|sor|>Most people don't know a lot about randomness, so i think it's easy to see how you could naively assume that a long period meant it was "more random"<|eor|><|eols|><|endoftext|>
12
lolphp
Ipswitch84
ce105mm
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Because rand() is included for historical reasons (PHP doesn't know how to let bad things die), but mt_rand() is consistent across systems. Also, see this discussion http://www.reddit.com/r/lolphp/comments/1pvf3h/phps_mt_rand_random_number_generating_function/ .<|eor|><|sor|>rand() is a PHP proxy function for libc's rand(). mt_rand() is an implementation of Mersenne Twister, which is longer period PRNG. Neither is useful as a true source of randomness for cryptography, but can be useful for other situations where a PRNG is acceptable.<|eor|><|eols|><|endoftext|>
11
lolphp
Ipswitch84
ce1038c
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>Also, mt_rand uses a mersenne twister, which isn't cryptographically secure, so depending on use case, you might need an even better one.<|eor|><|sor|>For some reason people think it's good just because it has a very long period (2^19937 - 1)<|eor|><|sor|>MT is useful in simulation since it is long period. Not a lot of simulation software written in PHP, however.<|eor|><|eols|><|endoftext|>
10
lolphp
blueskin
ce5iw63
<|sols|><|sot|>Why.<|eot|><|sol|>http://i.imgur.com/Htg0feG.png<|eol|><|sor|>function nsa_rand Generate a... ah... better one... because the NSA told us to add it.<|eor|><|eols|><|endoftext|>
9
lolphp
Miserable_Fuck
6x8t6h
<|sols|><|sot|>"This argument doesn't do anything. Should we ship it?" "Sure! Why not!"<|eot|><|sol|>https://i.redd.it/yr5h24bfb4jz.png<|eol|><|eols|><|endoftext|>
127
lolphp
SituationSoap
dme859b
<|sols|><|sot|>"This argument doesn't do anything. Should we ship it?" "Sure! Why not!"<|eot|><|sol|>https://i.redd.it/yr5h24bfb4jz.png<|eol|><|sor|>I feel like I'm missing some context, here.<|eor|><|eols|><|endoftext|>
45
lolphp
myhf
dmeosdb
<|sols|><|sot|>"This argument doesn't do anything. Should we ship it?" "Sure! Why not!"<|eot|><|sol|>https://i.redd.it/yr5h24bfb4jz.png<|eol|><|sor|>I feel like I'm missing some context, here.<|eor|><|sor|>That's ok!<|eor|><|eols|><|endoftext|>
17
lolphp
the_alias_of_andrea
dmf6zf2
<|sols|><|sot|>"This argument doesn't do anything. Should we ship it?" "Sure! Why not!"<|eot|><|sol|>https://i.redd.it/yr5h24bfb4jz.png<|eol|><|sor|>What function is that? <|eor|><|sor|>It's [copy](https://secure.php.net/manual/en/function.copy.php) and this is the commit with the fix in if you're interested https://github.com/php/php-src/commit/ac73c9d8b41a6d862b2719109d33e551b7a9b83d<|eor|><|sor|>> After looking at the logs, Jani did a bad merge into 5.3 Sounds like the feature was implemented correctly the first time, but someone made a mistake when resolving merge conflicts. or rather several mistakes, by the looks of it. :/<|eor|><|eols|><|endoftext|>
16
lolphp
sproingie
dmlqbwb
<|sols|><|sot|>"This argument doesn't do anything. Should we ship it?" "Sure! Why not!"<|eot|><|sol|>https://i.redd.it/yr5h24bfb4jz.png<|eol|><|sor|>Still not adding unit tests to go along with a feature, eh PHP devs?<|eor|><|eols|><|endoftext|>
11
lolphp
Radio0002
dmect06
<|sols|><|sot|>"This argument doesn't do anything. Should we ship it?" "Sure! Why not!"<|eot|><|sol|>https://i.redd.it/yr5h24bfb4jz.png<|eol|><|sor|>What function is that? <|eor|><|sor|>It's [copy](https://secure.php.net/manual/en/function.copy.php) and this is the commit with the fix in if you're interested https://github.com/php/php-src/commit/ac73c9d8b41a6d862b2719109d33e551b7a9b83d<|eor|><|eols|><|endoftext|>
10
lolphp
bj_christianson
dmfhj59
<|sols|><|sot|>"This argument doesn't do anything. Should we ship it?" "Sure! Why not!"<|eot|><|sol|>https://i.redd.it/yr5h24bfb4jz.png<|eol|><|sor|>I feel like I'm missing some context, here.<|eor|><|sor|>Nothing that cant be ignored.<|eor|><|eols|><|endoftext|>
9
lolphp
RichardEyre
dme2cey
<|sols|><|sot|>"This argument doesn't do anything. Should we ship it?" "Sure! Why not!"<|eot|><|sol|>https://i.redd.it/yr5h24bfb4jz.png<|eol|><|sor|>What function is that? <|eor|><|eols|><|endoftext|>
8
lolphp
HurfMcDerp
2xw6n2
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|eoss|><|endoftext|>
130
lolphp
mrspoogemonstar
cp3yqj6
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|> function (){throw new ;} class extends Exception {public function __construct() {parent::__construct("Please respect tables! (_)");} public function __toString(){return "";}} // try/catch try { (); } catch ( $niceguy) {echo $niceguy->getMessage();} // ok now lets see an uncaught one ();<|eor|><|eoss|><|endoftext|>
82
lolphp
barubary
cp3xyck
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>I think this is for fake Unicode support in source code. In UTF-8, any non-ascii character will be encoded with bytes in the `[\x80-\xff]` range, so any Unicode letter is automatically valid in a PHP function name (of course, any Unicode non-letter will also be accepted). Or maybe this was for 8-bit character sets that are supersets of ASCII, like ISO 8859-1. Of course, this rule would still accept non-letters like . I have no idea what they were thinking when they allowed `\x7F`. That *is* an ascii character, DEL. Definitely not a letter.<|eor|><|eoss|><|endoftext|>
28
lolphp
Hrukjan
cp3zyrv
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|> function (){throw new ;} class extends Exception {public function __construct() {parent::__construct("Please respect tables! (_)");} public function __toString(){return "";}} // try/catch try { (); } catch ( $niceguy) {echo $niceguy->getMessage();} // ok now lets see an uncaught one ();<|eor|><|sor|>Just in case someone thought that was invalid code: http://3v4l.org/NJJjO<|eor|><|eoss|><|endoftext|>
28
lolphp
bart2019
cp3yu3v
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>So you can have a function whose name is the nonbreaking space: `"\xa0"`.<|eor|><|eoss|><|endoftext|>
23
lolphp
mrspoogemonstar
cp413j3
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|> function (){throw new ;} class extends Exception {public function __construct() {parent::__construct("Please respect tables! (_)");} public function __toString(){return "";}} // try/catch try { (); } catch ( $niceguy) {echo $niceguy->getMessage();} // ok now lets see an uncaught one ();<|eor|><|sor|>You can actually use utf-8 identifiers in a lot of languages.<|eor|><|eoss|><|endoftext|>
20
lolphp
PleaseRespectTables
cp3yqzg
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|> function (){throw new ;} class extends Exception {public function __construct() {parent::__construct("Please respect tables! (_)");} public function __toString(){return "";}} // try/catch try { (); } catch ( $niceguy) {echo $niceguy->getMessage();} // ok now lets see an uncaught one ();<|eor|><|sor|>A man filled with the gladness of living Put his keys on the table, Put flowers in a copper bowl there. He put his eggs and milk on the table. He put there the light that came in through the window, Sounds of a bicycle, sound of a spinning wheel. The softness of bread and weather he put there. On the table the man put Things that happened in his mind. What he wanted to do in life, He put that there. Those he loved, those he didn't love, The man put them on the table too. Three times three make nine: The man put nine on the table. He was next to the window next to the sky; He reached out and placed on the table endlessness. So many days he had wanted to drink a beer! He put on the table the pouring of that beer. He placed there his sleep and his wakefulness; His hunger and his fullness he placed there. Now that's what I call a table! **It didn't complain at all about the load.** It wobbled once or twice, then **stood firm.** The man kept piling things on.<|eor|><|eoss|><|endoftext|>
20
lolphp
vytah
cp43lr9
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>Reddit hacked up the regex, here it is in its full regexy glory: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*<|eor|><|eoss|><|endoftext|>
19
lolphp
thallippoli
cp3ydn2
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>>Maybe something like that weird $() thing from jQuery?" Are you being funny or did you just show your idiotic ineptitude? It's called an identifier, you moron, and it's part of the languange construct. That "weird" symbol "in jQuery" is valid in every language based on ECMAScript. And it's a valid mapped character in ASCII. Therefore valid. God, the people who post to this sub the most are the least qualified to call themselves "programmers". Oh, I have a valid "weird" identifier name for you, OP: _<|eor|><|sor|>Classic PHP user response. Takes the most irrelevant part of your comment and make a big fuss over it, completely derailing the discussion in a couple of comments... I guess, this is why these guys does not learn anything past a certain point....You can find veteran PHP programmers who have written books and talks at conferences who does not understand or have a gross misunderstanding of programming concepts...<|eor|><|eoss|><|endoftext|>
19
lolphp
VeXCe
cp41zzj
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>I think this is for fake Unicode support in source code. In UTF-8, any non-ascii character will be encoded with bytes in the `[\x80-\xff]` range, so any Unicode letter is automatically valid in a PHP function name (of course, any Unicode non-letter will also be accepted). Or maybe this was for 8-bit character sets that are supersets of ASCII, like ISO 8859-1. Of course, this rule would still accept non-letters like . I have no idea what they were thinking when they allowed `\x7F`. That *is* an ascii character, DEL. Definitely not a letter.<|eor|><|soopr|>I figured as much. I tried `\xFF` first and it found it was ``, which makes sense. But non-printing characters? That's just asking for trouble.<|eoopr|><|sor|>As if anyone is going to use those. Oh wait, PHP users. Yep, you're right.<|eor|><|eoss|><|endoftext|>
19
lolphp
callcifer
cp4j4yw
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>I don't see how this is a problem. Just because you can use hilariously shitty function "names" doesn't mean you have to. And it's not really a concern that it could happen accidentally, either. PHP has 99 problems but this ain't one.<|eor|><|sor|>The language shouldn't enable such retarded behaviour (non-printing chars as identifiers) in the first place. This is bad design, pure and simple.<|eor|><|eoss|><|endoftext|>
18
lolphp
callcifer
cp4xidg
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>I don't see how this is a problem. Just because you can use hilariously shitty function "names" doesn't mean you have to. And it's not really a concern that it could happen accidentally, either. PHP has 99 problems but this ain't one.<|eor|><|sor|>The language shouldn't enable such retarded behaviour (non-printing chars as identifiers) in the first place. This is bad design, pure and simple.<|eor|><|sor|>Why? Just because the language support UTF-8 names for variables and methods doesn't make it bad. This is valid Ruby: irb(main):001:0> def irb(main):002:1> " Let is go " irb(main):003:1> end => : irb(main):004:0> puts Let is go => nil irb(main):005:0><|eor|><|sor|>I specifically said **non-printing chars**. I'm fine with Unicode chars as long as I can actually see them.<|eor|><|eoss|><|endoftext|>
18
lolphp
simonorono
cp3zcsz
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>>Maybe something like that weird $() thing from jQuery?" Are you being funny or did you just show your idiotic ineptitude? It's called an identifier, you moron, and it's part of the languange construct. That "weird" symbol "in jQuery" is valid in every language based on ECMAScript. And it's a valid mapped character in ASCII. Therefore valid. God, the people who post to this sub the most are the least qualified to call themselves "programmers". Oh, I have a valid "weird" identifier name for you, OP: _<|eor|><|sor|>Classic PHP user response. Takes the most irrelevant part of your comment and make a big fuss over it, completely derailing the discussion in a couple of comments... I guess, this is why these guys does not learn anything past a certain point....You can find veteran PHP programmers who have written books and talks at conferences who does not understand or have a gross misunderstanding of programming concepts...<|eor|><|sor|>> I guess, this is why these guys does not learn anything past a certain point....You can find veteran PHP programmers who have written books and talks at conferences who does not understand or have a gross misunderstanding of programming concepts... Why don't you post your opinions with your real username? Anonymity is a great platform from which to spew childish vitriol, but you're not going to convince anyone of anything while you troll out one side and speak actual opinions out the other.<|eor|><|sor|>Nice work derailing the discussion. BTW, by "real" username do you mean actual name? Because I think that mrspoogemonstar is not a "real" name. Complaining about anonymity on the Internet it's just plain stupid to me.<|eor|><|eoss|><|endoftext|>
14
lolphp
Sarcastinator
cp3zpcr
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>http://3v4l.org/1esIu edit: made a more clear example.<|eor|><|eoss|><|endoftext|>
13
lolphp
HurfMcDerp
cp3y1ci
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>I think this is for fake Unicode support in source code. In UTF-8, any non-ascii character will be encoded with bytes in the `[\x80-\xff]` range, so any Unicode letter is automatically valid in a PHP function name (of course, any Unicode non-letter will also be accepted). Or maybe this was for 8-bit character sets that are supersets of ASCII, like ISO 8859-1. Of course, this rule would still accept non-letters like . I have no idea what they were thinking when they allowed `\x7F`. That *is* an ascii character, DEL. Definitely not a letter.<|eor|><|soopr|>I figured as much. I tried `\xFF` first and it found it was ``, which makes sense. But non-printing characters? That's just asking for trouble.<|eoopr|><|eoss|><|endoftext|>
13
lolphp
HurfMcDerp
cp3y9kw
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>[deleted]<|eor|><|soopr|>That is exactly what the code that sparked my curiosity was doing, and I understand why it would be done that way. But the delete character? Is there some obscure use case I don't know about?<|eoopr|><|eoss|><|endoftext|>
13
lolphp
polish_niceguy
cp3y44s
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>I think this is for fake Unicode support in source code. In UTF-8, any non-ascii character will be encoded with bytes in the `[\x80-\xff]` range, so any Unicode letter is automatically valid in a PHP function name (of course, any Unicode non-letter will also be accepted). Or maybe this was for 8-bit character sets that are supersets of ASCII, like ISO 8859-1. Of course, this rule would still accept non-letters like . I have no idea what they were thinking when they allowed `\x7F`. That *is* an ascii character, DEL. Definitely not a letter.<|eor|><|soopr|>I figured as much. I tried `\xFF` first and it found it was ``, which makes sense. But non-printing characters? That's just asking for trouble.<|eoopr|><|sor|>Or very elaborate pranks ;)<|eor|><|eoss|><|endoftext|>
12
lolphp
sli
cqypefh
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|> function (){throw new ;} class extends Exception {public function __construct() {parent::__construct("Please respect tables! (_)");} public function __toString(){return "";}} // try/catch try { (); } catch ( $niceguy) {echo $niceguy->getMessage();} // ok now lets see an uncaught one ();<|eor|><|sor|>Just in case someone thought that was invalid code: http://3v4l.org/NJJjO<|eor|><|sor|>HHVM's output cracks me up: Fatal error: Uncaught <|eor|><|eoss|><|endoftext|>
10
lolphp
allthediamonds
cp5qm9f
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>I don't see how this is a problem. Just because you can use hilariously shitty function "names" doesn't mean you have to. And it's not really a concern that it could happen accidentally, either. PHP has 99 problems but this ain't one.<|eor|><|sor|>The language shouldn't enable such retarded behaviour (non-printing chars as identifiers) in the first place. This is bad design, pure and simple.<|eor|><|sor|>Why? Just because the language support UTF-8 names for variables and methods doesn't make it bad. This is valid Ruby: irb(main):001:0> def irb(main):002:1> " Let is go " irb(main):003:1> end => : irb(main):004:0> puts Let is go => nil irb(main):005:0><|eor|><|sor|>Supporting Unicode names is not a bad thing. The Unicode standard specifies a list of recommended characters for programming language identifiers, which is, essentially, a list of printable characters sans some exceptions. `DEL` is obviously not on that list.<|eor|><|eoss|><|endoftext|>
9
lolphp
serendependy
cp4lv1i
<|soss|><|sot|>"Nameless" labels.<|eot|><|sost|>I was browsing a GitHub repo of a PHP project when I noticed a weird function being used: `__("some text");`. "Huh, that's a weird function name," I thought, "I wonder what else you can use. Maybe something like that weird $() thing from jQuery?" I open up the docs for user defined functions and find this (emphasis mine): >Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: **[a-zA-Z\_\\x7f-\\xff][a-zA-Z0-9\_\\x7f-\\xff]***. Hold the phone, what's with those hex values? I had a python interpreter open in another window so i quickly type out `print("\\x7f")` only to get a blank line. What? I then fire up charmap and lookup what that character actually is. It's the DELETE character. You can have a function named the delete charater. http://3v4l.org/OAIGL Waitamintute. >**Function names follow the same rules as other labels in PHP.** So, I can have empty variable names too? http://3v4l.org/jo0tq Yup. I'm at a loss for words. <|eost|><|sor|>>Maybe something like that weird $() thing from jQuery?" Are you being funny or did you just show your idiotic ineptitude? It's called an identifier, you moron, and it's part of the languange construct. That "weird" symbol "in jQuery" is valid in every language based on ECMAScript. And it's a valid mapped character in ASCII. Therefore valid. God, the people who post to this sub the most are the least qualified to call themselves "programmers". Oh, I have a valid "weird" identifier name for you, OP: _<|eor|><|sor|>Classic PHP user response. Takes the most irrelevant part of your comment and make a big fuss over it, completely derailing the discussion in a couple of comments... I guess, this is why these guys does not learn anything past a certain point....You can find veteran PHP programmers who have written books and talks at conferences who does not understand or have a gross misunderstanding of programming concepts...<|eor|><|sor|>> I guess, this is why these guys does not learn anything past a certain point....You can find veteran PHP programmers who have written books and talks at conferences who does not understand or have a gross misunderstanding of programming concepts... Why don't you post your opinions with your real username? Anonymity is a great platform from which to spew childish vitriol, but you're not going to convince anyone of anything while you troll out one side and speak actual opinions out the other.<|eor|><|sor|>>Why don't you post your opinions with your real username? Anonymity is a great platform from which to spew childish vitriol, but you're not going to convince anyone of anything while you troll out one side and speak actual opinions out the other. The sheer lack of self awareness here leads me to think you are intentionally trolling.<|eor|><|eoss|><|endoftext|>
9
lolphp
Altreus
ps6x5
<|soss|><|sot|>0x0 wat<|eot|><|sost|> >>> 0x0 +2 4 >>> 0x0 +3.5 6.5 >>> 0x0 +2e1 757 :| Here is an explanation I was provided with: <mauke> once their lexer detects "0x", it skips all '0's, then calls strtol() <mauke> so: tokptr = "0x0 +2;", toklen = 3 <mauke> skip 0x: tokptr = "0 +2;", toklen = 1 <mauke> skip all '0's: tokptr = " +2;", toklen = 0 <mauke> call strtol(" +2", NULL, 16) ==> 2 <mauke> then it proceeds to parse the remaining program starting from " +2;" because that's where the previous token ends <mauke> and this is how 0x0 ends up having the value 2 <mauke> 0x0 +2e1 ends up being 757 because the first pass interprets 2e1 as a hex integer while the second pass thinks it's a floating point number <mauke> so it's really 0x2e1 + 2.0e1 I'm going to end up with one a day at this rate. Edit: fixed to not scroll horizontally<|eost|><|eoss|><|endoftext|>
126
lolphp
throwaway-o
c3rt9vz
<|soss|><|sot|>0x0 wat<|eot|><|sost|> >>> 0x0 +2 4 >>> 0x0 +3.5 6.5 >>> 0x0 +2e1 757 :| Here is an explanation I was provided with: <mauke> once their lexer detects "0x", it skips all '0's, then calls strtol() <mauke> so: tokptr = "0x0 +2;", toklen = 3 <mauke> skip 0x: tokptr = "0 +2;", toklen = 1 <mauke> skip all '0's: tokptr = " +2;", toklen = 0 <mauke> call strtol(" +2", NULL, 16) ==> 2 <mauke> then it proceeds to parse the remaining program starting from " +2;" because that's where the previous token ends <mauke> and this is how 0x0 ends up having the value 2 <mauke> 0x0 +2e1 ends up being 757 because the first pass interprets 2e1 as a hex integer while the second pass thinks it's a floating point number <mauke> so it's really 0x2e1 + 2.0e1 I'm going to end up with one a day at this rate. Edit: fixed to not scroll horizontally<|eost|><|sor|>Their lexer is psychotic.<|eor|><|eoss|><|endoftext|>
28
lolphp
ealf
c3sgjxg
<|soss|><|sot|>0x0 wat<|eot|><|sost|> >>> 0x0 +2 4 >>> 0x0 +3.5 6.5 >>> 0x0 +2e1 757 :| Here is an explanation I was provided with: <mauke> once their lexer detects "0x", it skips all '0's, then calls strtol() <mauke> so: tokptr = "0x0 +2;", toklen = 3 <mauke> skip 0x: tokptr = "0 +2;", toklen = 1 <mauke> skip all '0's: tokptr = " +2;", toklen = 0 <mauke> call strtol(" +2", NULL, 16) ==> 2 <mauke> then it proceeds to parse the remaining program starting from " +2;" because that's where the previous token ends <mauke> and this is how 0x0 ends up having the value 2 <mauke> 0x0 +2e1 ends up being 757 because the first pass interprets 2e1 as a hex integer while the second pass thinks it's a floating point number <mauke> so it's really 0x2e1 + 2.0e1 I'm going to end up with one a day at this rate. Edit: fixed to not scroll horizontally<|eost|><|sor|>This is a bug right? But... why is it skipping the initial zeroes?<|eor|><|sor|>The initial zero in 0x is skipped, because it just means "This following number is hexadecimal". The second 0 in "0x0 +2" is skipped, because its a zero, and, as we all know, 02 == 2. That is, all prefixing zeros are skipped, because they mean nothing. The real bug here is that the lexer actually passes the "+2" bit twice, because of the way it handles the "0x0" part.<|eor|><|sor|>> The initial zero in 0x is skipped, because it just means "This following number is hexadecimal". This is good. > The second 0 in "0x0 +2" is skipped, because its a zero, and, as we all know, 02 == 2. Why are they skipping it? strtol is perfectly capable of handling leading zeros.<|eor|><|sor|>["Optimization"](https://github.com/php/php-src/commit/0accb4b0094b8fdda905e0a374843f0c775f4537). Bonus points for the sprintf overflows in the first half of the commit.<|eor|><|eoss|><|endoftext|>
12
lolphp
EdiX
c3s43c7
<|soss|><|sot|>0x0 wat<|eot|><|sost|> >>> 0x0 +2 4 >>> 0x0 +3.5 6.5 >>> 0x0 +2e1 757 :| Here is an explanation I was provided with: <mauke> once their lexer detects "0x", it skips all '0's, then calls strtol() <mauke> so: tokptr = "0x0 +2;", toklen = 3 <mauke> skip 0x: tokptr = "0 +2;", toklen = 1 <mauke> skip all '0's: tokptr = " +2;", toklen = 0 <mauke> call strtol(" +2", NULL, 16) ==> 2 <mauke> then it proceeds to parse the remaining program starting from " +2;" because that's where the previous token ends <mauke> and this is how 0x0 ends up having the value 2 <mauke> 0x0 +2e1 ends up being 757 because the first pass interprets 2e1 as a hex integer while the second pass thinks it's a floating point number <mauke> so it's really 0x2e1 + 2.0e1 I'm going to end up with one a day at this rate. Edit: fixed to not scroll horizontally<|eost|><|sor|>This is a bug right? But... why is it skipping the initial zeroes?<|eor|><|eoss|><|endoftext|>
9
lolphp
Porges
c3s0kbs
<|soss|><|sot|>0x0 wat<|eot|><|sost|> >>> 0x0 +2 4 >>> 0x0 +3.5 6.5 >>> 0x0 +2e1 757 :| Here is an explanation I was provided with: <mauke> once their lexer detects "0x", it skips all '0's, then calls strtol() <mauke> so: tokptr = "0x0 +2;", toklen = 3 <mauke> skip 0x: tokptr = "0 +2;", toklen = 1 <mauke> skip all '0's: tokptr = " +2;", toklen = 0 <mauke> call strtol(" +2", NULL, 16) ==> 2 <mauke> then it proceeds to parse the remaining program starting from " +2;" because that's where the previous token ends <mauke> and this is how 0x0 ends up having the value 2 <mauke> 0x0 +2e1 ends up being 757 because the first pass interprets 2e1 as a hex integer while the second pass thinks it's a floating point number <mauke> so it's really 0x2e1 + 2.0e1 I'm going to end up with one a day at this rate. Edit: fixed to not scroll horizontally<|eost|><|sor|>WHAT THE<|eor|><|eoss|><|endoftext|>
6
lolphp
Pesthuf
6gtwcs
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|eoss|><|endoftext|>
122
lolphp
sloat
dit2dv8
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|sor|>I believe this has something to do with an incorrect DST calculation. If you explicitly add timezone info to your date strings, it works (e.g. '2017-06-01T00:00:00 UTC'). It also seems that anything with a positive offset (i.e. european TZs) are broken. Try CEST instead of UTC, then PDT. Timezones and daylight-savings are convoluted, so it's a bit more forgivable. Still, this should have been covered in a unit test.<|eor|><|eoss|><|endoftext|>
38
lolphp
Pesthuf
dit2o1i
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|sor|>I believe this has something to do with an incorrect DST calculation. If you explicitly add timezone info to your date strings, it works (e.g. '2017-06-01T00:00:00 UTC'). It also seems that anything with a positive offset (i.e. european TZs) are broken. Try CEST instead of UTC, then PDT. Timezones and daylight-savings are convoluted, so it's a bit more forgivable. Still, this should have been covered in a unit test.<|eor|><|soopr|>I see. Yeah, a unit test actually was was made me catch this. Thank you for the explanation. Although this makes this entire situation even worse than I initially thought... PHP datetime handling really is a mess. Is there any composer package that attempts to fix it?<|eoopr|><|eoss|><|endoftext|>
21
lolphp
sloat
dit3aw5
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|sor|>I believe this has something to do with an incorrect DST calculation. If you explicitly add timezone info to your date strings, it works (e.g. '2017-06-01T00:00:00 UTC'). It also seems that anything with a positive offset (i.e. european TZs) are broken. Try CEST instead of UTC, then PDT. Timezones and daylight-savings are convoluted, so it's a bit more forgivable. Still, this should have been covered in a unit test.<|eor|><|soopr|>I see. Yeah, a unit test actually was was made me catch this. Thank you for the explanation. Although this makes this entire situation even worse than I initially thought... PHP datetime handling really is a mess. Is there any composer package that attempts to fix it?<|eoopr|><|sor|>Oh, I meant the PHP team should have had a unit test that covered this ;) But yeah, it's good that you caught this. File a bug report if you want to (probably) continue the laughs. Edit: Looks like something similar [here](https://bugs.php.net/bug.php?id=52480)<|eor|><|eoss|><|endoftext|>
20
lolphp
Pesthuf
dit3cmf
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|sor|>I believe this has something to do with an incorrect DST calculation. If you explicitly add timezone info to your date strings, it works (e.g. '2017-06-01T00:00:00 UTC'). It also seems that anything with a positive offset (i.e. european TZs) are broken. Try CEST instead of UTC, then PDT. Timezones and daylight-savings are convoluted, so it's a bit more forgivable. Still, this should have been covered in a unit test.<|eor|><|soopr|>I see. Yeah, a unit test actually was was made me catch this. Thank you for the explanation. Although this makes this entire situation even worse than I initially thought... PHP datetime handling really is a mess. Is there any composer package that attempts to fix it?<|eoopr|><|sor|>Oh, I meant the PHP team should have had a unit test that covered this ;) But yeah, it's good that you caught this. File a bug report if you want to (probably) continue the laughs. Edit: Looks like something similar [here](https://bugs.php.net/bug.php?id=52480)<|eor|><|soopr|>I'm not really laughing. I'm just frustrated. Didn't my post radiate enough passive aggressiveness? This wasted almost my entire day.<|eoopr|><|eoss|><|endoftext|>
15
lolphp
sloat
dit9psj
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|sor|>I believe this has something to do with an incorrect DST calculation. If you explicitly add timezone info to your date strings, it works (e.g. '2017-06-01T00:00:00 UTC'). It also seems that anything with a positive offset (i.e. european TZs) are broken. Try CEST instead of UTC, then PDT. Timezones and daylight-savings are convoluted, so it's a bit more forgivable. Still, this should have been covered in a unit test.<|eor|><|sor|>In that case it's not wrong, surely? If there's a timezone change between two dates, then the time difference between them will be shorter or longer than normally expected. EDIT: except PHP doesn't say it's 30 days and 23 hours away, it says it's 30 days. Wow. :/<|eor|><|sor|>It happens even if there is no difference in the timezones, but only if the TZ offset is > 0. [https://3v4l.org/F6Nbg](https://3v4l.org/F6Nbg)<|eor|><|eoss|><|endoftext|>
11
lolphp
ZiggyTheHamster
diukgm5
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|sor|>I believe this has something to do with an incorrect DST calculation. If you explicitly add timezone info to your date strings, it works (e.g. '2017-06-01T00:00:00 UTC'). It also seems that anything with a positive offset (i.e. european TZs) are broken. Try CEST instead of UTC, then PDT. Timezones and daylight-savings are convoluted, so it's a bit more forgivable. Still, this should have been covered in a unit test.<|eor|><|soopr|>I see. Yeah, a unit test actually was was made me catch this. Thank you for the explanation. Although this makes this entire situation even worse than I initially thought... PHP datetime handling really is a mess. Is there any composer package that attempts to fix it?<|eoopr|><|sor|>Oh, I meant the PHP team should have had a unit test that covered this ;) But yeah, it's good that you caught this. File a bug report if you want to (probably) continue the laughs. Edit: Looks like something similar [here](https://bugs.php.net/bug.php?id=52480)<|eor|><|soopr|>I'm not really laughing. I'm just frustrated. Didn't my post radiate enough passive aggressiveness? This wasted almost my entire day.<|eoopr|><|sor|>More wasted days are on the horizon if you keep working in PHP.<|eor|><|eoss|><|endoftext|>
9
lolphp
coredumperror
ditngex
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|sor|>This is probably the same underlying problem that cost me several days of work on a Drupal module I was writing a few years back. Some of the edge cases for getting dates right led to utterly *bonkers* results from date arithmetic. Stuff like "Jan 31" + 1 day = "Mar 3" (it wasn't that exact thing, but similarly lolphp).<|eor|><|eoss|><|endoftext|>
8
lolphp
poop-trap
diug6mw
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|sor|>Programming time is hard enough without your language sticking its finger in your eye. I'm guessing leap years and leap seconds don't exist either.<|eor|><|eoss|><|endoftext|>
6
lolphp
InconsiderateBastard
dit2ghh
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|sor|>Check the difference between 2017-05-02 and 2017-06-02 :-D<|eor|><|eoss|><|endoftext|>
5
lolphp
Pesthuf
diujpfw
<|soss|><|sot|>All months have 31 days.<|eot|><|sost|>I should have known. Of course I should have known. So, what do you think is the Difference between 2017-**05-01** and 2017-**06-01**? You got that right, of course it's 1 month. https://3v4l.org/ZsDWN And what is the difference in months between 2017-**06-01** and 2017-**07-01**? You're right again, it's zero. After all, the difference is only 30 days, and as we all know, all months have 31 days. https://3v4l.org/BeQKI I can almost see the **MONTH = DAY * 31** in some C array in the PHP source in front of me... <|eost|><|soopr|>What's also interesting is that the difference between the sixth and eight month is calculated correctly. (2 months) https://3v4l.org/GQB4O Also it says that the difference is 30 days and not something like 29 days and 23 hours. That's why I don't think that daylight savings or timezone differences are to blame for this.<|eoopr|><|eoss|><|endoftext|>
5
lolphp
tias
mwpstr
<|sols|><|sot|>A story of what it took to convince the PHP community to replace T_PAAMAYIM_NEKUDOTAYIM with a useful error message<|eot|><|sol|>https://phil.tech/2013/wtf-is-t-paamayim-nekudotayim/<|eol|><|eols|><|endoftext|>
122
lolphp
tias
gvjjxuf
<|sols|><|sot|>A story of what it took to convince the PHP community to replace T_PAAMAYIM_NEKUDOTAYIM with a useful error message<|eot|><|sol|>https://phil.tech/2013/wtf-is-t-paamayim-nekudotayim/<|eol|><|soopr|>I think this story exemplifies a pattern that I sometimes see among software developers (and it surely exists in other businesses as well). Some people, when unable to see the technical solution for a problem, will manufacture superficial reasons for why it isn't a problem in the first place. After all the discussion of how there's a legacy that needs to be preserved, about teaching people about other human languages, or the patronizing "if you don't understand this you shouldn't be a developer" (a lot of it really bizarre in comparison with the problem at hand), it ends with an anticlimax when someone just proposes a simple solution with predictable consequences. Upon which Rasmus himself (who argued against the change because he "liked" the way it was) says "this was the intent, but I didn't think there was a clean way to do that". As with many human problems, I suspect there's fear at the root of it. Subconsciously they are insecure, worrying that they aren't smart enough to solve it well. They feel that changing things will disrupt the safe zone of what they know. Because the consequences don't feel predictable it is potentially dangerous to them. Judging from the way the PHP discussions often go, it would seem the PHP community has a disproportionate share of such people.<|eoopr|><|eols|><|endoftext|>
50
lolphp
Altreus
gvm2c8x
<|sols|><|sot|>A story of what it took to convince the PHP community to replace T_PAAMAYIM_NEKUDOTAYIM with a useful error message<|eot|><|sol|>https://phil.tech/2013/wtf-is-t-paamayim-nekudotayim/<|eol|><|soopr|>I think this story exemplifies a pattern that I sometimes see among software developers (and it surely exists in other businesses as well). Some people, when unable to see the technical solution for a problem, will manufacture superficial reasons for why it isn't a problem in the first place. After all the discussion of how there's a legacy that needs to be preserved, about teaching people about other human languages, or the patronizing "if you don't understand this you shouldn't be a developer" (a lot of it really bizarre in comparison with the problem at hand), it ends with an anticlimax when someone just proposes a simple solution with predictable consequences. Upon which Rasmus himself (who argued against the change because he "liked" the way it was) says "this was the intent, but I didn't think there was a clean way to do that". As with many human problems, I suspect there's fear at the root of it. Subconsciously they are insecure, worrying that they aren't smart enough to solve it well. They feel that changing things will disrupt the safe zone of what they know. Because the consequences don't feel predictable it is potentially dangerous to them. Judging from the way the PHP discussions often go, it would seem the PHP community has a disproportionate share of such people.<|eoopr|><|sor|>I think you give them too much credit when you say they cant see the technical solution. I dont think you need to justify their attitude with some underlying rationality. Ive been around programming communities enough - PHP especially - where people act like this because they have some inexplicable emotional connection to something inert. People resist change *because its change* and try to rationalise their irrational response with nonsense that feels exactly like trolling. This sounds very similar to the drama that made Sawyer X step down from Perl core.<|eor|><|eols|><|endoftext|>
14
lolphp
tobiasvl
gvl8sfy
<|sols|><|sot|>A story of what it took to convince the PHP community to replace T_PAAMAYIM_NEKUDOTAYIM with a useful error message<|eot|><|sol|>https://phil.tech/2013/wtf-is-t-paamayim-nekudotayim/<|eol|><|sor|>Your post title made me think they'd actually replaced the token name, but that's not the case, right? They just added the :: literal to the error message so people can understand it somewhat?<|eor|><|eols|><|endoftext|>
12
lolphp
smog_alado
gvq14h4
<|sols|><|sot|>A story of what it took to convince the PHP community to replace T_PAAMAYIM_NEKUDOTAYIM with a useful error message<|eot|><|sol|>https://phil.tech/2013/wtf-is-t-paamayim-nekudotayim/<|eol|><|sor|>My favorite part of this story is that even after Felipe suggested the simple and obvious solution, the code that landed on PHP 5.4 was more complicated just to appease the conservatives. They added a custom error formatting function, going out of their way to ensure that the error message would still show the internal token names. In order for this to work they also had to manually write the internal token name inside the token description for every token. Felipe's proposal: %token T_PAAMAYIM_NEKUDOTAYIM :: What they actually used: %token T_PAAMAYIM_NEKUDOTAYIM ":: (T_PAAMAYIM_NEKUDOTAYIM)" ------ PHP 5.3 (before): * [token declaration]( https://github.com/php/php-src/blob/7311087cf06bf9f3d6b5863d9b54272f3d163ba9/Zend/zend_language_parser.y#L146) PHP 5.4 (after): * [token declaration](https://github.com/php/php-src/blob/a12cef979db2466dd98d46cffd0a32c6eb2957c3/Zend/zend_language_parser.y#L207) * [custom error function](https://github.com/php/php-src/blob/a12cef979db2466dd98d46cffd0a32c6eb2957c3/Zend/zend_language_parser.y#L1173) The good news is that it seems that PHP 8.0 finally removed the internal token name from the error message. The vestigial custom error function is still there, however. Over the years it has accumulated even more complexity.<|eor|><|eols|><|endoftext|>
7
lolphp
tending
gvm1wn5
<|sols|><|sot|>A story of what it took to convince the PHP community to replace T_PAAMAYIM_NEKUDOTAYIM with a useful error message<|eot|><|sol|>https://phil.tech/2013/wtf-is-t-paamayim-nekudotayim/<|eol|><|soopr|>I think this story exemplifies a pattern that I sometimes see among software developers (and it surely exists in other businesses as well). Some people, when unable to see the technical solution for a problem, will manufacture superficial reasons for why it isn't a problem in the first place. After all the discussion of how there's a legacy that needs to be preserved, about teaching people about other human languages, or the patronizing "if you don't understand this you shouldn't be a developer" (a lot of it really bizarre in comparison with the problem at hand), it ends with an anticlimax when someone just proposes a simple solution with predictable consequences. Upon which Rasmus himself (who argued against the change because he "liked" the way it was) says "this was the intent, but I didn't think there was a clean way to do that". As with many human problems, I suspect there's fear at the root of it. Subconsciously they are insecure, worrying that they aren't smart enough to solve it well. They feel that changing things will disrupt the safe zone of what they know. Because the consequences don't feel predictable it is potentially dangerous to them. Judging from the way the PHP discussions often go, it would seem the PHP community has a disproportionate share of such people.<|eoopr|><|sor|> >Some people, when unable to see the technical solution for a problem, will manufacture superficial reasons for why it isn't a problem in the first place. <|eor|><|eols|><|endoftext|>
7
lolphp
beerdude26
gvm0r1l
<|sols|><|sot|>A story of what it took to convince the PHP community to replace T_PAAMAYIM_NEKUDOTAYIM with a useful error message<|eot|><|sol|>https://phil.tech/2013/wtf-is-t-paamayim-nekudotayim/<|eol|><|soopr|>I think this story exemplifies a pattern that I sometimes see among software developers (and it surely exists in other businesses as well). Some people, when unable to see the technical solution for a problem, will manufacture superficial reasons for why it isn't a problem in the first place. After all the discussion of how there's a legacy that needs to be preserved, about teaching people about other human languages, or the patronizing "if you don't understand this you shouldn't be a developer" (a lot of it really bizarre in comparison with the problem at hand), it ends with an anticlimax when someone just proposes a simple solution with predictable consequences. Upon which Rasmus himself (who argued against the change because he "liked" the way it was) says "this was the intent, but I didn't think there was a clean way to do that". As with many human problems, I suspect there's fear at the root of it. Subconsciously they are insecure, worrying that they aren't smart enough to solve it well. They feel that changing things will disrupt the safe zone of what they know. Because the consequences don't feel predictable it is potentially dangerous to them. Judging from the way the PHP discussions often go, it would seem the PHP community has a disproportionate share of such people.<|eoopr|><|sor|>Not sure it's not just "if it ain't broke, don't fix it", which is often a valid strategy. (Agreed that not in this case, just saying that a bit of fear is a good engineering practice. :))<|eor|><|sor|>More like "If it ain't broke and we ain't touching it for maintenance, it'll be broke soon"<|eor|><|eols|><|endoftext|>
5
lolphp
tr4ce
27ya0m
<|sols|><|sot|>PHP Streetfighter<|eot|><|sol|>http://imgur.com/iy6ymbc<|eol|><|eols|><|endoftext|>
122
lolphp
ajmarks
ci5kkj9
<|sols|><|sot|>PHP Streetfighter<|eot|><|sol|>http://imgur.com/iy6ymbc<|eol|><|sor|>This is more lolunmaintainablecode than lolphp, but it's still pretty funny.<|eor|><|eols|><|endoftext|>
44
lolphp
jb2386
ci5kvrk
<|sols|><|sot|>PHP Streetfighter<|eot|><|sol|>http://imgur.com/iy6ymbc<|eol|><|sor|>This isn't specific to PHP, it's just bad programming. But I like the creativity of streetfighter!<|eor|><|eols|><|endoftext|>
24
lolphp
vytah
ci5rtov
<|sols|><|sot|>PHP Streetfighter<|eot|><|sol|>http://imgur.com/iy6ymbc<|eol|><|sor|>This is more lolunmaintainablecode than lolphp, but it's still pretty funny.<|eor|><|sor|>I'm disappointed that there isn't a lolunmaintainablecode reddit.<|eor|><|sor|>/r/badcode and /r/programminghorror<|eor|><|eols|><|endoftext|>
23
lolphp
gavintlgold
ci5ofp5
<|sols|><|sot|>PHP Streetfighter<|eot|><|sol|>http://imgur.com/iy6ymbc<|eol|><|sor|> $user = read_user(..); and then later create_user(); Global variables based on $_POST input? I wonder if they used PDO or even escaped anything....<|eor|><|sor|>:)<|eor|><|sor|>Aww, the bot thought I was sad because I posted PHP code. Cute.<|eor|><|eols|><|endoftext|>
22
lolphp
DontBeSadBOT
ci5odc0
<|sols|><|sot|>PHP Streetfighter<|eot|><|sol|>http://imgur.com/iy6ymbc<|eol|><|sor|> $user = read_user(..); and then later create_user(); Global variables based on $_POST input? I wonder if they used PDO or even escaped anything....<|eor|><|sor|>:)<|eor|><|eols|><|endoftext|>
16
lolphp
allthediamonds
ci5sgkz
<|sols|><|sot|>PHP Streetfighter<|eot|><|sol|>http://imgur.com/iy6ymbc<|eol|><|sor|>At first I thought it was skewed that way with photoshop. When it hit me that that was the actual code I almost got sick to my stomach :/<|eor|><|sor|>Well, at least it's indented...<|eor|><|eols|><|endoftext|>
9
lolphp
OneWingedShark
ci63uif
<|sols|><|sot|>PHP Streetfighter<|eot|><|sol|>http://imgur.com/iy6ymbc<|eol|><|sor|>Jesus Christ that's not what the fucking session is for. <|eor|><|sor|>> Jesus Christ that's not what the fucking session is for. ***sigh*** - You and I both know that, but as a *very slight* defense here webprogramming is seriously deficient here -- HTTP was really meant for *stateless* services/objects, and tacking state onto that is a source of a*lot* of their troubles. (The other big source, IMO, is trying to use HTML [and CSS] to specify *layout* -- HTML was specifically designed to allow the reader to choose the proper layout [i.e. **strong**-tags could be rendered with James Earl Jones in an audio-reader for visually impaired users.]) IME, When you start going against the design-goals that your tools were targeting you get (a) bad workarounds, and/or (b) maintainability issues.<|eor|><|eols|><|endoftext|>
9
lolphp
Breaking-Away
ci66uda
<|sols|><|sot|>PHP Streetfighter<|eot|><|sol|>http://imgur.com/iy6ymbc<|eol|><|sor|> $user = read_user(..); and then later create_user(); Global variables based on $_POST input? I wonder if they used PDO or even escaped anything....<|eor|><|sor|>:)<|eor|><|sor|>Aww, the bot thought I was sad because I posted PHP code. Cute.<|eor|><|sor|>DontCommitSuicideBot<|eor|><|eols|><|endoftext|>
5
lolphp
Takeoded
ecdhl0
<|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|eols|><|endoftext|>
121
lolphp
Altreus
fbapn04
<|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>"This language can't stop you from doing something stupid." Well it fucking should. Other languages manage it.<|eor|><|eols|><|endoftext|>
55
lolphp
andsens
fbb88is
<|sols|><|sot|>segfault is intended behavior, not a bug.<|eot|><|sol|>https://bugs.php.net/bug.php?id=49664<|eol|><|sor|>> [2015-03-19 19:52 UTC] omars@php.net > I'd say the best way to handle this, could be using an ini directive. And there we have it, the proper fix for any PHP problem.<|eor|><|eols|><|endoftext|>
40