1

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?

3
  • not sure what you mean? showing some code may help Commented Mar 1, 2011 at 21:04
  • include('yourfile') to actually run the code and set the variables? Commented Mar 1, 2011 at 21:05
  • quite unclear what you want, there are a dozen ways to interpret this question. Commented Mar 1, 2011 at 21:32

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.