Jump to content

Stop executing required script


dotkpay

Recommended Posts

Is there a way or function that stops the execution of a required script but continues to execute the parent script, for example:

 

if this is a.php

 

<?php

echo "<br>Good morning";

 

// function to stop execution of only this script to appear here

 

echo "<br>Good Afternoon";

?>

 

and then this is b.php

 

<?php

 

require("a.php');

 

echo "<br>Good Evening";

?>

 

So if the file b.php is called it is supposed to display:

 

Good morning

Good evening

 

So it has to skip "Good afternoon" because of the anonymous function which I need

Link to comment
Share on other sites

You should not think of the required/included code as a separate script that is being 'called'. Think of it as source code (function definitions, class definitions, configuration information) that the main program needs to use to accomplish some goal.

 

When the require/include statement in the parent script is executed, the required/included code is executed in the scope of the parent script. The required/included code might be stored in a separate file and in a different folder, but when it is executed, it is the same as if you had copy/pasted the source code from the required/included file into the parent script at the point where the require/include statement is at.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.