Jump to content

Running a function from within a module, except when part of an "include"


johnsiilver

Recommended Posts

I'm attempting to do something that other languages like python seem to make easy, and so I'm sure php has a way to do it, though I've never seen code that does.

What I want to be able to do is write modules that include functions, sometimes just one function. Ex:

===================
file: example.php
===================
function blah()
{
echo "blah";
}

blah();


==================

I want to be able to call the function blah() from another file, but I don't want the function call to blah() that is in the file to happen when I do the include("example.php") in whatever file that is going to call the blah() function.

The reason I want to do this is I write a bunch of functions all in seperate files that get called by an index.php page and puts all the output of the functions in a dom draggable <div>. But I also want to be able to access the function on it's own page by directly navigating to the module.

Is there some way to not execute a piece of code if it's being caused by an include() or require()?

Thanks.
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.