PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 2, 2022

[FIXED] CakePHP - Utility method for checking a string is a valid email address?

 March 02, 2022     cakephp, cakephp-1.3, email-validation, php     No comments   

Issue

In a controller, I need to check a string to see if it is a valid email address. Is there an existing method in Cake that I can use to check this?

It has nothing to do with models, so I don't want to use a validate array.


Solution

I found the core Validation class. Validation::email()

App::uses('Validation', 'Utility');

class MyController extends AppController
{
    public function myAction()
    {
        $isValid = Validation::email('person@example.com'); // Returns true or false
    }
}


Answered By - BadHorsie
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing