9

First time me ranting about PHP.

First time. I still really like the language.

But what the fuck.
I am debugging, I narrowed down bug to my validator.
I played with php console and debugger and narrowed down to that one offending line.

Narrowing down to smaller and smaller examples when it dosent work, confusion and tension grows in me.

And then it hit me.
Confusion got to apogeum.

Anyone, if you know the anwser, please tell me.
WHAT THE FUCK?

maybe thats task for stack overflow? Hrm...
No, I dont have time to explicitly tell what I tried to google and spend 4 hours to have all checkmarks ticked before asking lol

Comments
  • 2
    Which PHP version is that? Everything 3v4l runs gets it right... https://3v4l.org/LbXr0
  • 1
    Looks okay to me. https://3v4l.org/fifOV
  • 0
    7.3

    Im confused as fuck.

    Seriously. Im still scratching my head about this -_-

    Edit:
    On eval its allright too. On other machine with pinpoint same version its fine too....

    Whaaaaat the hell ;-;
  • 3
    > I still really like the language.

    Give it time...
  • 4
    @watzon

    Given it few years. I still like it. And even, I like it more and more.

    PHP hate is reserved for people who didn't give it enough time or attention. But that's my opinion, I elaborated on it so many times its getting boring.
  • 3
    @DubbaThony I've worked with it for years and can't stand it. I've generally found that people who have worked pretty exclusively with PHP love it, but anyone that's worked with a more friendly language like Ruby can't stand PHP. I'm the latter.
  • 2
    @watzon

    Before PHP I was from passion dealing with CPP and ansi C.

    I really like all of these 3, but if Im to choose what to code in from these 3, all my money goes onto PHP (unless its windowed app, than cpp + QT).

    So in theory I should hate php but I don't.

    My friend, knowing that I like idea of low-level code tried to show me few "more friendly" languages, namely:

    - Go lang
    - Rust
    - some weird java-based thing I dont remember name of, but it was weird as fu*k
    (...)

    And you know what? All of them were for me "what about no?"
  • 1
    @DubbaThony it actually makes sense that you'd like PHP if you have C experience. PHP is basically just a high level wrapper around C.
  • 2
    @watzon so what's my problem?
    I've been a php for 10 years
    I also work with Java and python but still run back to my sexy girl.
  • 2
    @C0D4

    topic is opinion based, some will hate, some will love.

    I just hope that @watzon 's complain is educated one, not like most of flame that PHP gets.

    Imagine now here the big stack overflow's badge "opinion based" ;)

    EDIT:
    before anyone complains that I overuse "hate" word.
  • 2
    @C0D4 some people are just weird πŸ˜‰
  • 1
    @DubbaThony as for your issue, this looks fine πŸ€”

    Not on a pc/laptop at the moment so hard to debug in a phone πŸ˜”
  • 0
    Non strict compression always have some issue like this. That's why you should aways make the strict true.
  • 1
    @watzon I know, i just wear my weirdness with pride. People tend to think me be crazies πŸ˜…
  • 0
    @C0D4

    I have no idea why its broken on my main machine, but on second machine it's fine, so I guess my php install is corrupt somehow.

    I guess...

    It will be mystery for me and probably for everyone out there.
  • 1
    @C0D4 then again you mentioned two languages that I hate more than PHP, so...
  • 1
    @DubbaThony 🀨probably something minor in the .ini file

    Same version, and OS?
  • 0
    @marcus5914

    non-strict should happy-trigger with unneeded true's not false's ;-;
  • 1
    @C0D4 nope completly different enviroments.

    One is windows machine, other is linux machine.

    E:
    but PHP version is same, and plugins same too. I will copy over php.ini to check.

    E2:
    php.ini copied over. Still works on second machine.
  • 1
    @DubbaThony there are some inconsistencies with windows and Linux for some functions, it's always been a thing and drives you insane.

    I just hope you're not using x86 on windows and x64 on Linux or visa versus πŸ˜‚
  • 1
    @C0D4

    nah, x86.. man, my machines arent that old ;)

    anyway, I doubt THIS function has this kind of issues.

    I avoid OS-dependant functions as much as possible heh. Im aware of them ;)
  • 1
    @DubbaThony πŸ€”I know arrays are one of those weird ones if you were working with floats/ints (key being larger then 32bit) but for string based keys it should be the same.
  • 1
    So is this freaking out because you’ve set it as false and it’s throwing true?
  • 1
    @C0D4 string-based keys are one of my favourite features of php ^^

    Yeah, yeah, dictionaries etc.. But ability to use it as array, name it array and treat it as array is purefect :D

    and no int-overflow issues.

    Here, this array has few elements, it wouldnt overflow 8 bit int ;)
  • 1
    @DubbaThony I do enjoy $arr['whoot_i_is_key']

    Nah, dicts are close but not as flexible in strict types languages πŸ˜…

    I mean I can have a multi-dimensional, multi-type keys (map/dict) and ain't nothing wrong with that, besides confusing the next guy.
  • 2
    @badcopnodonuts it should be throwing true. First line

    Makes sense that in strict mode it does the right thing (true as 3rd argument) on third line

    But first and second lines are ultimately the same.

    I'm thinking it's a windows thing πŸ˜…
  • 2
    @C0D4

    For example. very fresh for me, Im making something that allows render text on image. It's "virtual gift card" kind of thing.

    and I have this array element:
    $coords[0]["tlc"]["x"]

    where 0 is just first string to put on the image, tlc is top left corner and x is well.. x from x/y

    remixing array key types is purefect :) And how much more readable than $coords[0][0][0] for example :)
  • 1
    @DubbaThony god dam yea.
    I hate having multi-dimensional arrays with just iterators for indexes, it's like - wtf am I even doing down here?

    I have a bad habit of doing this kind of thing but I do come from the dark ages

    $x[0]["name"] makes a lot more sense to where you are over [0][0]
  • 1
  • 1
    @C0D4 Sometimes these make sense, but often times you can make your structures SO MUCH MORE readable with simple ["cough-cough string indexes"] :)
  • 1
    @watzon i kinda see your point. But i have worked with many langs, from C# and Java to Python, Ruby, JS, TypeScript, and even Clojure(managed to use it at work) and still love php 🀷‍♂️ its a very "get shit done" lang.

    Then again I don't dislike any langs. Even worked with VBScript at one point and liked it.
  • 0
    @AleCx04 I'm very picky about syntax, speed, and other tradeoffs. I've used too many languages to mention, but I could definitely tell you the worst parts of all of them. PHP just happens to be super far down the list for me. I can't stand the syntax (it's basically just an HTML templating language) and it's not near as fast as most of the languages I use.

    The only exception for me is Laravel. Somehow Jeffery managed to make PHP not suck with that framework. I don't know how he did it, but he's a miracle worker.
  • 1
    @watzon i can't fault people for disliking syntax man haha its a preference thing. To me there are a couple of them that just have horrible syntax. Still, I recognize the value in what they bring to the table and still enjoy them for some reason. Mainly the money they bring to me.
    I must say though, Laravel does not add any layer of abstraction into the syntax of PHP, merely architectural idioms, maybe what you don't dig is seeing people abuse PHP as a template language.
    For me I really do enjoy the syntax. I am still trying to find a language that I would just completely abhor. Been programming for a while and still have not found one(VBScript should pretty much give you a good guesstimation of the time)
  • 1
    @DubbaThony man I love Go but the syntax is ugly af
  • 0
    @AleCx04

    For me acceptable syntax is honestly just one, other syntaxes are plain annoing to horrible depending on example. C-derrived syntax is πŸ‘Œ

    So java, even JS is bearable for this only purpose, etc.

    Thats when we talk syntax.
  • 0
    As mentioned before by others, PHP is built on top of C. You can use this fact to explain the behavior of underlying implementation of in_array. Use gdb to start PHP and run the script. This has helped me in the past to resolve some issues in PHP.

    There are some articles on the internet which explain how to, but it require at least some basic knowledge of C.
  • 1
    @Hel8y Whoa, debugging PHP with gdb? That's mildly insane :D
  • 0
    @Hel8y it was some wtf error in my machine, reinstalled php and its πŸ‘Œ
  • 0
    @gronostaj Kind of insane indeed, but after a few hours of trial and error gdb was my last option for solving the bug :)
Add Comment