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

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Eradication
Forum Newbie
Posts: 10
Joined: Sun Dec 21, 2003 11:37 pm
Location: USA

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

Post 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?
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post 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().
Eradication
Forum Newbie
Posts: 10
Joined: Sun Dec 21, 2003 11:37 pm
Location: USA

Post 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? ----------------------------------------------------------------------------.
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post 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.
Eradication
Forum Newbie
Posts: 10
Joined: Sun Dec 21, 2003 11:37 pm
Location: USA

Post 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.
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post 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.
Eradication
Forum Newbie
Posts: 10
Joined: Sun Dec 21, 2003 11:37 pm
Location: USA

Post by Eradication »

awww lol, ok JavaScript it is ;P
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
Post Reply