RE: [PHP] Problems with require() and variables

2003-01-16 Thread Ford, Mike [LSS]
 -Original Message-
 From: Phil Powell [mailto:[EMAIL PROTECTED]]
 Sent: 16 January 2003 04:33
 
 I have view.php, a script that will include display.php and 
 have to manipulate the variables within display.php for itself.
 
 So in view.php I have:
 
 require('/.../.../display.php');
 
 However, when display.php finishes being required, I lose 
 all of my variables that I need for view.php.  How do I 
 retain them??

You don't need to -- the included file is effectively part of the including file, so 
all variables available in one are equally available in the other.

  How can I ensure that these variables in 
 display.php will also exist in view.php?

By doing nothing.  You must be doing something else wrong.  Show us your code (or a 
relevant sample, if it's big!).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: RE: [PHP] Problems with require() and variables

2003-01-16 Thread Ford, Mike [LSS]
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: 16 January 2003 14:35
 To: [EMAIL PROTECTED]

Copying this back to the list, in case anyone else can contribute (although I think 
the attachments will be stripped -- can you make them available on a URL?).

 
 Ok, there they are, but they are quite large in size, I warn you.
 
 Basic concept is this:
 
 view.php: It will require display.php
 display.php: It will open a file (profile.xml), perform xml 
 parsing into a
 3-dim array of content, $profileArray
 view.php: will parse contents of $profileArray and display 
 flagged profile
 set up by $profileArray[$index]

Yes, I understand (although no having used the XML functions, I can't vouvh for the 
validity of your parsing strategy!).

 
 The problem is that $profileArray and $index both seem to vanish upon
 exiting the required code of display.php unless I store them 
 in a session
 variable.

Well, as you're using old-style $HTTP_SESSION_VARS session variables, these should act 
identically to any other variables in your script vis-a-vis the include file.  And I 
can't see any reason why your $profileArray shouldn't be exactly what you want it to 
be in view.php.  So, let's try a bit of simple debugging:  what do you see if you put

   echo 'prevar_dump=';
   var_dump($index, $profileArray[$index]);
   echo /pre\n;

as the very last bit of PHP in display.php, and the same in view.php immediately after 
the include statement (before the echo 4profileUserID...)?  You should get identical 
results (even if wrong ones!) -- if not, something *very* weird is happening.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php