Rakib
Rakib

Reputation: 13085

stop php execution instead of just a php script in codeigniter

I am using Codeigniter for a project and i usually call a series of models (let's say controllerA -> modelA -> modelB -> modelC) for some work. I want the php to stop executing when it reaches some exception where i invoke the exit() command. Now, if the command exit() is invoked in modelB, will it stop execution of only the script of modelB and continue executing rest of the modelA? Or will it stop the entire execution flow.

I really don't know how to put this question here. The question looks quite messy. Please let me know should i need to revise the question itself.

Upvotes: 0

Views: 1701

Answers (5)

Kaii
Kaii

Reputation: 20540

Yes, exit stops all script execution immediately, regardless where you call it.

The opposite is return which only stops execution of the current function (or current file when used at global level in an included file)

Read more here: https://stackoverflow.com/a/9853554/43959

Upvotes: 6

Md Eftakhairul Islam
Md Eftakhairul Islam

Reputation: 198

It stops the execution from that line.

Upvotes: 2

Philip
Philip

Reputation: 4592

Like someone mentions above you should return from a function, or If your in a loop you could use continue or break

Upvotes: 0

user1297515
user1297515

Reputation: 126

Wherever you call the exit() function, all code will stop executing. This includes the other files because codeigniter just 'requires' them.

Upvotes: 2

Lobo
Lobo

Reputation: 4147

I'm not sure if what you want, but maybe you can use exceptions to control PHP code execution.

http://es.php.net/manual/en/class.exception.php

Regards!

Upvotes: 0

Related Questions