physaux Posted November 20, 2009 Share Posted November 20, 2009 I have a function, <?php function myfunction($var1){ if($var1=="none"){ kill; } ... } ?> How can I abort the function, at the point of "kill" -I know I could just wrap the rest of the function in a opposite if statement, but I specifically want to just have an escape function, as my "escape point" might be deep in brackets next time, bla bla I know you can escape out of loops(don't remember the exact way but idc), so I am wondering if you can from functions? *the function does not return any value Link to comment https://forums.phpfreaks.com/topic/182244-solved-how-to-escape-kill-abort-from-within-a-function/ Share on other sites More sharing options...
Alex Posted November 20, 2009 Share Posted November 20, 2009 You mean like die or exit? Link to comment https://forums.phpfreaks.com/topic/182244-solved-how-to-escape-kill-abort-from-within-a-function/#findComment-961664 Share on other sites More sharing options...
physaux Posted November 20, 2009 Author Share Posted November 20, 2009 this will just "skip" to the end of the function? Or will it stop my overall script? They are not very clear with it. I just want this as a "trigger" inside of a function, so that when it is called and the value is a unwanted one, it finishes. will this do the trick? It's confusing they say it terminates the php script. Link to comment https://forums.phpfreaks.com/topic/182244-solved-how-to-escape-kill-abort-from-within-a-function/#findComment-961683 Share on other sites More sharing options...
Alex Posted November 20, 2009 Share Posted November 20, 2009 Oh sorry, I thought you wanted to terminate the entire script. If you just want to break out of the current function use return Link to comment https://forums.phpfreaks.com/topic/182244-solved-how-to-escape-kill-abort-from-within-a-function/#findComment-961685 Share on other sites More sharing options...
physaux Posted November 20, 2009 Author Share Posted November 20, 2009 heh its that simple? I was afraid that return would crash if I didn't give it a value, and I didn't want to do that. Guess i just should have tested it thanks Link to comment https://forums.phpfreaks.com/topic/182244-solved-how-to-escape-kill-abort-from-within-a-function/#findComment-961686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.