Off-topic Talk Where overpaid, underworked S2000 owners waste the worst part of their days before the drive home. This forum is for general chit chat and discussions not covered by the other off-topic forums.

need php help

Thread Tools
 
Old Feb 14, 2002 | 09:59 AM
  #1  
The Reverend's Avatar
Thread Starter
Registered User
20 Year Member
 
Joined: Oct 2000
Posts: 2,560
Likes: 0
From: Studio City, CA
Default need php help

Is there any way I can pull a variable from another file without completely parsing/running/outputting the contents of that file?

Por ejemplo:

I have a file called variable_puller.php and a file called variable_holder.php. variable _puller needs to output the contents of $myVar, but NOTHING else. variable _holder.php contains the following:

<?
$myVar = "This is the variable content.";
?>





This text should NOT be displayed.






How do I get $myVar into variable_puller.php without displaying "This text should NOT be displayed." in the process????
Reply
Old Feb 14, 2002 | 10:19 AM
  #2  
The Reverend's Avatar
Thread Starter
Registered User
20 Year Member
 
Joined: Oct 2000
Posts: 2,560
Likes: 0
From: Studio City, CA
Default

is there a way to include or require while suppressing output???
Reply
Old Feb 14, 2002 | 10:21 AM
  #3  
josh3io's Avatar
Registered User
25 Year Member
 
Joined: Oct 2000
Posts: 2,584
Likes: 0
From: Mountain View
Default

use output buffering.

ob_start();
$foo = 'geepers';
?>
blah blah blah foobar baz zort fnord
<?
$cont = ob_get_contents();
ob_end_clean();

echo $foo;
?><?
echo $cont;
Reply
Old Feb 14, 2002 | 10:22 AM
  #4  
josh3io's Avatar
Registered User
25 Year Member
 
Joined: Oct 2000
Posts: 2,584
Likes: 0
From: Mountain View
Default

or put it all in a string instead.

$foo = 'geepers';
$cont = 'blah blah blah foobar gaz zort fnord';
Reply
Old Feb 14, 2002 | 10:40 AM
  #5  
The Reverend's Avatar
Thread Starter
Registered User
20 Year Member
 
Joined: Oct 2000
Posts: 2,560
Likes: 0
From: Studio City, CA
Default

Thank you, sir!!!

I had another way of doing it thanks to cjb80, but this way I can have it evaluate any expressions, etc and not output to the user until I'm ready.
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Jibb47
Off-topic Talk
33
Feb 4, 2004 04:55 AM
DC5 Kid
Off-topic Talk
0
Oct 3, 2003 06:59 AM
mingster
Off-topic Talk
5
Apr 11, 2001 09:26 PM




All times are GMT -8. The time now is 03:54 AM.