• (cs) in reply to

    Re: PHP Return statements.

    No, the parenthesis are not required.   I know that for "return" and "include" statements you can use the forms:

    return ($value);
    or
    return $value;

    include 'filename.inc';
    or
    include('filename.inc');

    I haven't RTFM or STFW about this, but it is definately true for "return, include, require, require_once" , and pretty sure it is true for all the built-in keywords that accept parameters, and possibly for any user-defined functions also.  I use PHP alot, but I haven't tried all the combinations.   My standard is to not use them for the aforementioned keywords, and to use them everywhere else.




  • (cs)

    Jesus, do you people even bother to read the thread? A grand total of five people mentioned python hours apart as if they were the first one to do so, three in a row, and two gave almost the exact same examples. Read before you reply, it helps to avoid making a wtf of yourself. >_>

    Is there also IsIntegerEx, IsIntegerEx2, and IsIntegerExFixed?

    Obviously, doing this in interpreted PHP is much too slow; the only efficient way to do this is to implement the function (and the rest of the numericFunctions) in C in the Zend layer, recompile, and require all users to use your modified PHPEx. Being able to generate bugs faster should trump being able to generate bugs on more systems. =D

  • (cs) in reply to foxyshadis

    Foxy, totally agreed regarding the redundant answers....

    I also love the gazillion "they must have gotten paid by lines of code" comments...   1 per thread is enough, truly!

  • (unregistered)

    Actually I see exactly what the problem is here. If you look at a definition of an integer (http://www.google.co.za/search?q=definition+integer) it is really just "A member of the set of positive whole numbers {1, 2, 3, . . . }, negative whole numbers {-1, -2, -3, . . . }, and zero {0}."

    Ok so by that definition (not the computer science definition but the mathamatical one) then this function does exactly that (positives only)

  • (cs) in reply to

    Anonymous, your comment makes no sense.

    I clicked on your link, and see all of the results including negative numbers, as does your reference to them, yet you end with the statement that it is correct in the mathematical sense because it returns only positives..  WTF?????

  • (cs) in reply to Blue

    Maybe he meant natural numbers. Only that even then his statement wouldn't hold true, as IsInteger isn't exactly coping too well with signs, be it plus or minus. Not to mention the hassle of whether or not zero is an element of the natural numbers.

    btw: anybody ever mentioned what good WTF this forum software would be? I can't remember ever running across a bulletin board that (nearly) REQUIRES javascript to be enabled...

  • (cs) in reply to finix

    finix, the topic of what a wtf the forum software code must be is frequently mentioned, yes. :)

  • (unregistered) in reply to
    :
    Hmm... yeah... But for those who really likes descriptive function-names, maybe these names are better:

    isTheParameterGivenToThisFunctionAnIntegerThatIsNotNegativeButMaybeEmpty ()
    isTheParameterThatIsGivenToThisFunctionAString_WhereEachCharIsBetween0And9IncludingBoth0And9_WhereTheIntergerThatTheseCharsRepresentsAreNotNegative_ByTheWayTheStringCouldBeEmpty Aswell() [:)]

    One of my colleagues would gladly name methods like that if we let him get away with it. We let him have the ServerTalkingGobbledyGookException on the grounds that it does clearly express the problem, but I'm sure he'd like to have methods like you describe.

    Pete

  • anonymous (unregistered)

    PHP is_integer doesn't handle strings. is_integer("500") returns false. is_numeric does not handle detection of integers. It will return true for every numeric value. intval does not handle detection of integers, because it returns "5000" for intval("50gggg00").

    none of your proposed solutions actually work to take an integer in string and return true for an integer and false for a non-integer.

Leave a comment on “IsInteger() ... really?”

Log In or post as a guest

Replying to comment #:

« Return to Article