Reply to Re: newbie question about include() and include_once() functions

Your name:

Reply:


Posted by Rik Wasmus on 11/29/07 19:54

On Thu, 29 Nov 2007 20:01:58 +0100, JP <jpsebasti@gmail.com> wrote:

> Folks,
>
> Real newbie here. I'm going through some tutorials and reading as much
> as possible to learn PHP.
>
> This is a simple question.
>
> I want to put a bunch of PHP functions into a file. These functions
> would be shared by a lot of different php scripts.
>
> I want to then include() or include_once() that file with the defined
> functions into each php script.
>
> The problem I'm having is that instead of including the file and thus
> defining the functions within my main script, the included files are
> being displayed as text.
>
> I read the following in a beginners tutorial named "Including Files in
> PHP - Beginner Tutorial" on the phpfreaks.com site
>
> "If you include a file, for example a plain text file that does not
> have the PHP open and close tags, the file will be displayed within
> the current PHP script."
>
>
> So I guess I'm confused.
>
> If I create my include file (lets call it functions.php)
>
> <?php
> function testfunct1 ($text)
> {
> echo "Received text " . $text . "\n";
> }
> ?>
>
> And then if I create the main script (lets call it main.php)
>
> <?php
> include ('functions.php');
> ?>
>
> I get an error because basically, I'm nesting <?php ?> tags.

Well, it may seem like that, but an include/require indeed kinf of
implicitly ends/restarts php-tags. So, what is the actual error you get?
And are you sure you use the filesystem to include it, not http?
--
Rik Wasmus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация