Re: [PHP] require_once(); questions

2001-07-07 Thread Chris Anderson

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]




Re: [PHP] require_once(); questions

2001-07-07 Thread Inércia Sensorial

  I guess I know what may be wrong. My function that includes the files, it
is called several times, with different arguments being passed.

  It is something like:

function LoadPositionedModules ($posv, $posh)
{
// $posv is vertical position, and $posh is horizontal position
// Inside it, something like:

SELECT file_to_include FROM table WHERE posv = '$posv' AND posh =
'$posh';

   // Then the fetch_array, include, etc...
}


  So if I call:

LoadPositionedModules ('Left', 'Center');

  And it includes files feeding the SQL. On this included file I define a
var:

$test = Show Me!;

  If I call again, but with different parameters:

LoadPositionedModules ('Left', 'Footer');

  Then I guess the problem is that I can't use the $test var from the first
included file. It's clear to me why I can't now, thanks.

  So I believe a solution would be to find out how to use this var outside
the function scope. That was my second question.. Anyone have any ideas? I
guess I could register it on a session, or return it...

--


  Julio Nobrega.

Yes, I am developing another 'Portal-System'
Have a look:
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]




Re: [PHP] require_once(); questions

2001-07-07 Thread Chris Anderson

Try putting GLOBAL infront of the var to give it the greater scope
- Original Message -
From: Chris Anderson [EMAIL PROTECTED]
To: Inércia Sensorial [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, July 07, 2001 8:50 PM
Subject: Re: [PHP] require_once(); questions


 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]




-- 
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]