5
rant1ng
6y

WHO CAN SPOT THIS STUPID PHP ERROR!

$string = "something.com"

if(strpos(".", $string))
echo " yep, there's a period";
else
echo "nope, fuck you there isn't";

output: "nope, fuck you there isn't"

me: wtf ??? fucking wasting my time on this fucking stupid tiny fucking error, goddamnit and each refresh takes 15 seconds because it involves calling all these apis from localhost, gmail, etc. arggg...

...for an hour, until I smacked my head so hard I'm in the hospital for a concussion

I hate when that happens.

Time to take a break.

Comments
  • 0
    @njpugh90 yes, we are, I just fixed it

    my editor would warn me of that
  • 1
    lol... yep, arguments.

    fuck sakes
  • 0
    @njpugh90 oh now, I was reading the docs, going wtf

    like, my eyes switched the arguments before the signal got to my brain, type of thing

    hate that
  • 2
    It's ($haystack, $needle) for this particular function iirc? 😕

    Screw PHP and its inconsistencies.
  • 2
    @Root yeah, sometimes its the other way around isn't it

    thats why i got mixed up, cuz I just finished using another function where the order was reversed

    arg

    anyway whatever, just pet peeve, waste of an hour on an amateur problem
  • 0
    @rant1ng It's one of many reasons why I consider the language itself amateur and terrible.
  • 0
    @Root well just, never noticed that..

    if I were php I'd at least have some consistency there

    wonder what else isn't so organized under the hood

    but then wtf I didn't create a programming language, now did I, maybe they got tired
  • 0
    @rant1ng There are so so many issues and internal inconsistencies. I don't want to get into it again, though, especially on my phone.

    The language has gotten better in recent versions, but many of the underlying design flaws cannot be fixed without rewriting most of it.
  • 0
    So negative numbers in php conditionals are converted to false?
  • 0
    @rant1ng they do try to fix some methods but to keep support for older scripts. So some methods accept the parameters in two orders.
  • 1
    You’re also missing a semicolon in line 1.

    Had an issue yesterday where filter_var() would periodically throw warnings because it decided to treat FILTER_VALIDATE_DOMAIN as a string literal instead of a constant, even though there were no quotes involved.

    Still haven’t figured out why *that* one happens...
  • 0
    Just try to look at php.net more often if you are on Chrome you can even type php.net and then hit tab, after that you can search for a native function

    Once you hit enter you get the native function's documentation
  • 0
    @incognito or if you are using duckduckgo !php (probably, didnt check)
  • 1
    If(strpos($needle, $haystack) !== false) { do stuff }
  • 1
    It’s actually strpos($haystack, $needle)
Add Comment