Author Topic: Fuck you PHP!  (Read 17703 times)

micah

  • A real person, on the Internet.
  • Ass Wipe
  • Posts: 6915
  • Karma: +58/-55
  • Truth cannot contradict truth.
    • micahj.com
Re: Fuck you PHP!
« Reply #15 on: June 28, 2018, 10:30:49 PM »
curious, what would you expect the outcome to be, casting a string as an integer?
"I possess a device, in my pocket, that is capable of accessing the entirety of information known to man.  I use it to look at pictures of cats and get in arguments with strangers."

Mike

  • Jackass In Charge
  • Posts: 11270
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Fuck you PHP!
« Reply #16 on: June 29, 2018, 12:54:33 AM »
Doing something similar in Python throws an exception.  That is what I would expect.  Or return null as that would signify that the operation failed.
« Last Edit: June 29, 2018, 05:27:13 PM by Mike »

micah

  • A real person, on the Internet.
  • Ass Wipe
  • Posts: 6915
  • Karma: +58/-55
  • Truth cannot contradict truth.
    • micahj.com
Re: Fuck you PHP!
« Reply #17 on: June 29, 2018, 03:20:29 PM »
ah, i see what you mean. Yeah, PHP can be pretty lenient with things that you'd think shouldn't work.  Learning typescript now and I'm seeing how strict other languages can really be.  It's a bit eye-opening.
"I possess a device, in my pocket, that is capable of accessing the entirety of information known to man.  I use it to look at pictures of cats and get in arguments with strangers."

Mike

  • Jackass In Charge
  • Posts: 11270
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Fuck you PHP!
« Reply #18 on: May 19, 2020, 01:18:38 PM »
Fuck you PHP!


php 
> echo "ajdfkladfklajfk"['success'] == true;


Results:
Code: [Select]
Warning: Illegal string offset 'success' in php shell code on line 1
1

Seriously?  Fuck you!

It is because the ['success'] in the above case returns `a`.

Does turn out that `=== true` does return false.

micah

  • A real person, on the Internet.
  • Ass Wipe
  • Posts: 6915
  • Karma: +58/-55
  • Truth cannot contradict truth.
    • micahj.com
Re: Fuck you PHP!
« Reply #19 on: May 19, 2020, 03:21:12 PM »
what are you even trying to do with that shit-code? Some context might help understand why this seems like a misguided error
"I possess a device, in my pocket, that is capable of accessing the entirety of information known to man.  I use it to look at pictures of cats and get in arguments with strangers."

Mike

  • Jackass In Charge
  • Posts: 11270
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Fuck you PHP!
« Reply #20 on: May 19, 2020, 03:44:23 PM »
Well, obviously that is not the actual code :)

This was part of the following:

    $options 
= [
        
'http' => [
            
'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
            
'method'  => 'POST',
            
'content' => http_build_query($data),
        ],
    ];
    
$context  stream_context_create($options);
    
$result file_get_contents($urlfalse$context);


The URL being called should have returned a JSON response which includes a `success` key that is a boolean.  However, due to the recent cutover the URL now returned a HTML string and the code continued on as normal like nothing was wrong.

Unfortunately, this is embedded in Wirepress code so I'm stuck with PHP for awhile :mad:

And now I've got to go and see if it ever worked and the best way to fix it.  /sigh