Page 1 of 1

In JavaScript You could Exit with "return;"InPHP??

Posted: Mon Dec 22, 2003 11:16 pm
by Eradication
I have a lot of code in this PHP file, and it searches for information that it receives, like age, address, etc. But if something goes wrong in the search (like the person is under 18 ), then I'd just do something, but I want the code to stop there, I don't want it to continue with the rest of the document to scan the rest of the information.

Do you use return; in PHP too?

Posted: Mon Dec 22, 2003 11:27 pm
by uberpolak
Depends what you want to do, return() will kill the function, but keep the script going. If you want to kill the whole thing, use die().

Posted: Mon Dec 22, 2003 11:32 pm
by Eradication
Cool, so how would you make the script die for a limited amount of time, so like the things are going ok on the road of scripting -------------------------------------------- but now I want to wait for like 2 seconds and then start on the road again where I left off? ----------------------------------------------------------------------------.

Posted: Mon Dec 22, 2003 11:38 pm
by uberpolak
I'm not sure what you mean. It sounds like you want to delay the execution for no reason, but that can't be right. Sorry, please explain more clearly.

Posted: Tue Dec 23, 2003 12:04 am
by Eradication
Well you see what's happening is this. The people first go to a form where they fill out like their name and address, and then once they click the button they get sent to this page with a text box that scans the data slowly. (because with computers these days they can scan anything in a heart beat), so I want to check the name for like 1 second, so that on the textbox it'll say "Name Valid". And then the code will check the Address for 1 second and display "Address Valid". etc...

Instead of the code instantaneously checking everything and being valid anyways, I want it to go slower, by stalling the code after every checkup. I hope that helps lol, I'll explain more if you want.

Posted: Tue Dec 23, 2003 12:08 am
by uberpolak
So you want to go back and forth between checking things and displaying them? If that's the case PHP isn't the tool you need. All your PHP code is parsed before the browser gets the page. You need a client-side language like JavaScript.

Posted: Tue Dec 23, 2003 12:44 am
by Eradication
awww lol, ok JavaScript it is ;P

Posted: Tue Dec 23, 2003 2:52 am
by JayBird
you could do it by submitting the form and using the [php_man]sleep[/php_man] function, then printing the results back yo the form