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.

Irsath
  • 46
  • 5

2 Answers2

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.

unm4sk
  • 335
  • 1
  • 8
0

In test2.php

include('test1.php');
echo $a;
Indrajit
  • 405
  • 4
  • 12