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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]