Jump to content


Photo

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


  • Please log in to reply
No replies to this topic

#1 johnsiilver

johnsiilver
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 16 May 2006 - 08:10 PM

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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users