10 Very Useful PHP Functions/Codes for PHP Developers – Part I

6 Responses

  1. Cerebro Vasconcelos says:

    functions to get precious hours of php developer

  2. md2perpe says:

    Why write (! $some_boolean_expression) ? FALSE : TRUE when you could just use (! $some_boolean_expression)

  3. Kristopher Wilson says:

    Most of these are crazy balls, but #9 is my favorite: How about just doing date(‘t’, strtotime(“$month/01/$year”)); ? or better yet: new DateTime(“$month/01/$year”)->format(‘t’); ?

  4. Radhad says:

    Please, learn PHP the right way!

    Your regular expression for email addresses is wrong. PHP has a very well builtin function to check if an email address is valid. Just have a look at the manual: http://www.php.net/manual/de/function.filter-var.php#refsect1-function.filter-var-examples

    Your random string generator is ok for random strings, but never (!!!!) use it for passwords or if you need a safe random string / value. There are much better ways from a security point of view, just look at https://github.com/padraic/SecurityMultiTool/blob/master/library/SecurityMultiTool/Random/Generator.php for a good implementation.

    And as Kristopher Wilson said, just use DateTime! http://php.net/DateTime

  5. Chaz Mead says:

    #1 is a very very week way of validating email, this should not be implemented as it has many many flaws. (ALSO #1, #2, #3, #4, #5, #6 have been copied word for word out of CodeIgniter!! perhaps you should give some credit where credit is due). thanks.

  6. gafitescudaniel says:

    No need to reinvent the wheel:

    For email validation:

    var_dump(filter_var(‘bob@example.com’, FILTER_VALIDATE_EMAIL));

Leave a Reply

Your email address will not be published. Required fields are marked *