Re: require_once(); questions
| From: | Chris Anderson | Date: | Sun, 08 Jul 2001 00:50:20 +0000 |
| Subject: | Re: require_once(); questions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56695@lists.php.net to get a copy of this message | ||
Actually this does work:
//First_File.php
<?
$test = "I am the test variable";
?>
//Second_File.php
<?
echo $test;
?>
//Active file
<?
require "First_File.php";
require "Second_File.php";
?>
That would produce the output of :
I am the test variable
An include or require just places the files' contents at the line you
include it. So after the includes(requires) my parsed code was:
<?
$test = "I am the test variable";
echo $test;
?>
Hope this helps
----- Original Message -----
From: "Inércia Sensorial" <inerte@hotmail.com>
To: <php-general@lists.php.net>
Sent: Saturday, July 07, 2001 5:59 PM
Subject: [PHP] require_once(); questions
> Hi All,
>
> I have a function that includes files based on some SQL queries. On one
of
> the first loaded files, I want to define a function and use it on another
> included file. Something like:
>
> includes file:
> first_file.inc.php
> This file has: $test = "Show me!";
>
> Then include file:
> second_file.php
> This file has: echo $test;
>
> But doesn't show nothing, so I guess it is not possible to do. Am I
right?
> If so, what's the best alternative?
>
> Also, another question.... since it is a function that includes the
files,
> the contents of these files are not available outside the function scope..
> what's the best way to use it outside the function?
>
> Thanks a lot....
>
> --
>
>
> Julio Nobrega.
>
> A hora está chegando:
> http://sourceforge.net/projects/toca
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>