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 6574593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:16:49+00:00 2026-05-25T15:16:49+00:00

I test user input both the client and server side. On the server side

  • 0

I test user input both the client and server side. On the server side there is a short simple class composed of static functions which validate user input. Class sign-up and sign-in call these functions. My concern is that I should not be using static functions. Should I be using static functions to validate user input? Thanks.

/*check*/

class check 
{
    static function empty_user($a)
    {
        return (int)!in_array('',$a); 
    }   

    static function name($a)
    {
        return preg_match('/^[a-zA-Z-\.\s]{1,40}$/',$a);
    }

    static function email($a)
    {
        return preg_match('/^[a-zA-Z0-9._s-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{1,4}$/',$a);
    }

    static function pass($a)
    {
        return preg_match('/^[a-zA-Z0-9!@#$%^&*]{6,20}$/',$a);
    }
}
  • 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-05-25T15:16:50+00:00Added an answer on May 25, 2026 at 3:16 pm

    The purpose of the class is ultimately not relevant for the decision about static vs. non-static member functions. What matters if objects of the class has a state, or if the class is merely a stand-in for a namespace.

    In the latter case, the class just collects a bunch of loosely related function in a common namespace, but you would never instantiate the class. In the former case, you should put all the data that’s common to the design purpose of the class into the class as private members and use those members in your (non-static) functions.

    In your example, I could see that you make $a a private member:

    class CheckInput
    {
        private $data;
    
        public function init($a) { $this->data = $a; } // or write a constructor
    
        public function email() { ... $this->data ... }
    
        // ...
    }
    

    That way, you instantiate one CheckInput object for each set of input data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to write tests where conditions like the following arise: Test user Input. Test
How would I go about posting a textarea form? <form method=post action=/user/test/shoutbox/add id=shoutPost class=clearit>
I have a script which takes user input, the REFRESH option is optional. I
I am trying to test user input, basically var1, var2 and var3, needs to
I need to have ha validity test to see if input from a user
I am attempting to test user interaction with an off the shelf product. The
from django.contrib.auth.models import User u = User.objects.get(username='test') user.password u'sha1$c6755$66fc32b05c2be8acc9f75eac3d87d3a88f513802 Is reversing this password encryption
In a ModelForm, i have to test user permissions to let them filling the
I need to test if a user can write to a folder before actually
Are user stories (typically used in agile development or test driven development) the same

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.