Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Some help

Name: Anonymous 2009-09-08 0:50

I had an idea of using the switch() function in PHP to switch the arguments inside of a function. Only thing is, it doesn't really work, and I am not sure why.

function VALIDATE_($value)
        {
        switch ($value) {
            case $user:
                return preg_match('/^[A-Z0-9]{2,20}$/i', $username);
                break;
            case $mail:
                return filter_var($email, FILTER_VALIDATE_EMAIL);
                break;
            }
        }


I am sure you can see what I am trying to do. I want it to work so that whenever I change $value to $user or $email the output is different depending on which I use.

But whenever I use VALIDATE_($mail);, it always uses the first case. Anyone have an idea on how I can fix this?

Name: Anonymous 2009-09-08 1:01

case $mail
whenever I change $value to $user or $email
Does this have anything to do with it?

If not you may want to pastebin.com post the whole file that you're having problems with.

Name: Anonymous 2009-09-08 1:09

>>2
Oh, no. That was a typo in my post.

Name: Anonymous 2009-09-08 1:11

Well, I haven't finished writing the file, but here it is so far.

http://pastebin.com/m2fb41632

Name: Anonymous 2009-09-08 1:22

I would suggest using regular expressions. Then you should have no problems.

Name: Anonymous 2009-09-08 1:42

>>1
What the fuck is $user and what is $mail? you want $this->fields["user"] and $this->fields["mail"] in the validate function.

Name: Anonymous 2009-09-08 1:51

>>6
Well he's got
$user   = new USERObject();

but I don't know where $mail is defined.  I think there's another page he needs to show us.  The one where he is calling the VALIDATE_ from or whatever

Name: Anonymous 2009-09-08 2:09

>>6
You are a fagstick. Gtfo.



Thanks, everyone else. I just decided to use an integer instead of a variable. Works great. So instead of VALIDATE_($user), I'll just use VALIDATE_(1). It was just a rookie mistake.

Name: Anonymous 2009-09-08 2:32

>>7
Hes got a variable local to that function? Cool bananas.
>>8
You're retarded. "Instead of making sound design decisions and carrying through with them, I'll just keep trying different things till it works and call it a day."

Name: Anonymous 2009-09-08 3:28

>>9

You are just to scared to do something different. You'll never get anywhere farther than you are now, because you will never invent something innovative.

Name: Anonymous 2009-09-08 3:51

ITT: WEB DEVELOPER QUALITY

Name: Anonymous 2009-09-08 5:25

>>11
Hell yeah. This thread is now about web languages.

How to mimic Java's ugly, verbose print function in PHP:

define("system", null);
define("out", null);

function printLn($val='')
    {
    echo $val;
    }

system.out.printLn("Hello world!");

Name: Anonymous 2011-02-03 3:37

Don't change these.
Name: Email:
Entire Thread Thread List