Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8878809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:48:09+00:00 2026-06-14T19:48:09+00:00

Got a quick question, I’m building a big website for a personal project and

  • 0

Got a quick question, I’m building a big website for a personal project and I think I’m looking at classes and functions for validation of forms and data etc.

My question I guess is:

Can I use a class to house all the functions that will validate dependant upon the data been passed and if so how can I target certain functions within the class (email addresses, phone numbers etc).

If my logic is right how would it look in code format?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:48:10+00:00Added an answer on June 14, 2026 at 7:48 pm

    You could define your validating functions statically within a class. Then include this class as and where you need it.

    class Validator {
    
        public static function validateEmail($email) {
            // validation logic for email
            // return true or false
        }
    
        public static function validatePhone($phone) {
            // validation logic for phone
            // return true or false
        }
    }
    
    // in a different file, where you want to use this class
    
    require('validator.php');
    $email = $_POST['email'];
    
    if (Validator::validateEmail($email)) {
        // valid email
    } else {
        // invalid email
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got a quick question, I am building an ASP.NET website and have a
I've got a quick question. In my grails project I am making some web
I've got a quick question about default values in PL/SQL functions in Oracle. Take
Hey guys got a quick question here, how do i set up TweetStream after
I am newbie to .Net and I got a quick question. In my web
I have this quick question, i have got the username variable from a form
I asked this question earlier and I got very quick and helpful responses: Linq
I've got a quick question that I hope someone can help me with. I'm
I've got a quick question regarding the use of repositories. But the best way
Hey everyone, got a quick question that I can't seem to find anything about...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.