RE: [PHP] Re: Revised - Call a Function from a Local File

From: Date: Wed, 07 May 2003 01:03:28 +0000
Subject: RE: [PHP] Re: Revised - Call a Function from a Local File
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146606@lists.php.net to get a copy of this message
You need <?php ?> tags around PHP code inside an include. When PHP encounters and include it exits the parser so you need tags to tell it to start parsing again. Do you understand what you are trying to accomplish? It does not appear so. You have tried function calls in arbitrary places and switching between using them as methods on an object and just functions. If you do not know what you are trying to do and with what it is going to be really hard for someone to help you, especially when it seems you do not understand PHP at all but are expecting someone to hold your hand and walk you through the basics. Maybe this seems a little harsh, but you are just trying stuff willy nilly and do not show any understanding of the language, which would imply you have done no research at all but expect something to just magically start working. You need to call the function where you expect it to execute. If the function is a method in a class you need to call it on an object, if not, you need to treat it as a function. If your script is just exiting after you include something either it is encountering an error, in which case it would print one to output and you should include it in your email, or there is something in the include telling it to end, such as a call to exit(). If it just starts executing code where ever the include is, the include probably contains inline code and not just functions or a class definition. If you expect meaningful help, you might want to post what is in your include. > -----Original Message----- > From: chris@wakeboarder.com [mailto:chris@wakeboarder.com] > Sent: Tuesday, May 06, 2003 5:54 PM > To: DvDmanDT > Cc: php-general@lists.php.net > Subject: Re: [PHP] Re: Revised - Call a Function from a Local File > > > I tried removing the <? ?> tags from the included file and I got > a long page > of code following the point of the include... Was that the right > thing to try? > > Chris > > > I've tried including the file that the functions are in, but > wherever I > > place > > > the include it draws the included file and disregards all of > my code after > > > the include. > > > > > > I've tried several different methods of calling the function, > including: > > > > > > <? > > > include("file.php"); > > > $call = new class(""); > > > $call->function(); > > > $call->function2(); > > > ?> > > > and > > > > > > <? > > > include("file.php"); > > > function(); > > > function2(); > > > ?> > > > > > > and also placing the includes at the beginning of the page with the > > function > > > calls at the position I want the menu bars. > > > > > > In all cases, where I place the include is where it starts drawing the > > > included file and disregarding my code. > > > > > > Any ideas?? > > >

« previous php.general (#146606) next »