Jump to content

Archived

This topic is now archived and is closed to further replies.

johnsiilver

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

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.

Share this post


Link to post
Share on other sites

×

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.