Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
How to pass the variables from one file to another, but only the variables, not the output of the file(content) . The ob_start isn't working for me, anything else?
ob_start
include('yourfile')
To pass a variable, you need to include your file
file1.php
<?php $variable = "hello world"; ?>
file2.php
<?php include ('file1.php') echo $variable; // hello world. ?>
and this is how you pass a variable from one file to another
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
include('yourfile')to actually run the code and set the variables?