Comments on: 10 Very Useful PHP Functions/Codes for PHP Developers – Part I https://w3lessons.info/10-very-useful-php-functionscodes-for-php-developers-part-i Tutorials on PHP, jQuery & Amazon Web Services Wed, 06 May 2020 03:04:52 +0000 hourly 1 https://wordpress.org/?v=6.6.2 By: gafitescudaniel https://w3lessons.info/10-very-useful-php-functionscodes-for-php-developers-part-i#comment-252 Sun, 22 Dec 2013 18:42:00 +0000 http://w3lessons.info/?p=1278#comment-252 No need to reinvent the wheel:

For email validation:

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

]]>
By: Chaz Mead https://w3lessons.info/10-very-useful-php-functionscodes-for-php-developers-part-i#comment-251 Thu, 19 Dec 2013 09:37:00 +0000 http://w3lessons.info/?p=1278#comment-251 #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.

]]>
By: Radhad https://w3lessons.info/10-very-useful-php-functionscodes-for-php-developers-part-i#comment-1446 Thu, 19 Dec 2013 09:30:00 +0000 http://w3lessons.info/?p=1278#comment-1446 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

]]>
By: Kristopher Wilson https://w3lessons.info/10-very-useful-php-functionscodes-for-php-developers-part-i#comment-250 Tue, 17 Dec 2013 14:10:00 +0000 http://w3lessons.info/?p=1278#comment-250 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’); ?

]]>
By: md2perpe https://w3lessons.info/10-very-useful-php-functionscodes-for-php-developers-part-i#comment-249 Sun, 15 Dec 2013 18:41:00 +0000 http://w3lessons.info/?p=1278#comment-249 Why write (! $some_boolean_expression) ? FALSE : TRUE when you could just use (! $some_boolean_expression)

]]>
By: Cerebro Vasconcelos https://w3lessons.info/10-very-useful-php-functionscodes-for-php-developers-part-i#comment-248 Mon, 05 Aug 2013 16:27:00 +0000 http://w3lessons.info/?p=1278#comment-248 functions to get precious hours of php developer

]]>