0

There are two files which names are test1.php and test2.php. test1.php have following lines

<?php
echo "hello world";
$a="test";
?>

test2.php have following lines

<?php
echo $a;
?>

but I can not display the $a in test2.php. What can I do to display $a value. please anyone help.

2
  • 4
    Include the file ? Commented Mar 14, 2016 at 10:34
  • Go and learn first about session and query string. Session cannot be destroyed only on page refresh. Commented Mar 14, 2016 at 10:46

2 Answers 2

1

If you want to use $a in test2.php, you need to include test1.php in test2.php file.

include('test1.php');

Keep in mind that including test1.php is also gonna echo your 'hello world' from test1.php.

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

Comments

0

In test2.php

include('test1.php');
echo $a;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.