p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: How can I stop a script - just stop it!


Message #1 by "Thomas" <sneaker@p...> on Fri, 15 Feb 2002 23:52:16
Hello

Imagine I just want to stop executing a script in the middle of it, 

without a reason, just a command that stops the script like it would be 

the end of the php file!



I guess it'll be something like

break;

exit;

stop;

or something but I'm not sure :)



BTW - Because this is my second post tonight you might've already guessed 

that I'm working on something :)



Greetz, sneax
Message #2 by "Thomas" <sneaker@p...> on Sat, 16 Feb 2002 00:21:31
Hello again :)

I coudn't w8 for an answer so I tryed a bit myself



break; didn't work (as expected coz it's for loops or something)

stop; didn't do the job either so I thought a bit of logical sense would 

come up with something usefull



So it tryed die(); with no comment.

It worked!!!

Is it safe to do?

If ($safe == "no")

{

  echo "There another way?";

}

elseif ($safe == "yes")

{

  echo "Are there other ways?";

}

else

{

  echo "Answer the question plz.";

}



:D (too much PHP 4 me 2night ;))



Greetz, sneax
Message #3 by "Nikolai Devereaux" <yomama@u...> on Fri, 15 Feb 2002 16:41:37 -0800

exit() or die().



you can pass a string to the function and it will echo it just before the

script terminates.



That's why a lot of people have "mysql_connect(...) or die('couldn't

connect')" in their scripts.



nik



> -----Original Message-----

> From: Thomas [mailto:sneaker@p...]

> Sent: Friday, February 15, 2002 11:52 PM

> To: beginning php

> Subject: [beginning_php] How can I stop a script - just stop it!

>

>

> Hello

> Imagine I just want to stop executing a script in the middle of it,

> without a reason, just a command that stops the script like it would be

> the end of the php file!

>

> I guess it'll be something like

> break;

> exit;

> stop;

> or something but I'm not sure :)

>

> BTW - Because this is my second post tonight you might've already guessed

> that I'm working on something :)

>

> Greetz, sneax




> $subst('Email.Unsub').



Message #4 by "sneax" <sneaker@p...> on Sat, 16 Feb 2002 02:12:36 +0100
Thnx



Greetz, sneax





----- Original Message -----

From: "Nikolai Devereaux" <yomama@u...>

To: "beginning php" <beginning_php@p...>

Sent: Saturday, February 16, 2002 1:41 AM

Subject: [beginning_php] RE: How can I stop a script - just stop it!





>

> exit() or die().

>

> you can pass a string to the function and it will echo it just before the

> script terminates.

>

> That's why a lot of people have "mysql_connect(...) or die('couldn't

> connect')" in their scripts.

>

> nik

>

> > -----Original Message-----

> > From: Thomas [mailto:sneaker@p...]

> > Sent: Friday, February 15, 2002 11:52 PM

> > To: beginning php

> > Subject: [beginning_php] How can I stop a script - just stop it!

> >

> >

> > Hello

> > Imagine I just want to stop executing a script in the middle of it,

> > without a reason, just a command that stops the script like it would be

> > the end of the php file!

> >

> > I guess it'll be something like

> > break;

> > exit;

> > stop;

> > or something but I'm not sure :)

> >

> > BTW - Because this is my second post tonight you might've already

guessed

> > that I'm working on something :)

> >

> > Greetz, sneax




> > $subst('Email.Unsub').

>

>




$subst('Email.Unsub').

>




  Return to Index