I have two files X.php and Y.php as shown below and I am not quite able to figure out what the include statement signifies. In both, these cases the code did not do what I expected it to do. So, I would like to know how it works.
Scenario 1: Variable defined in Y is used in X
X.php
<?php
include 'web/y.php';
echo $test;
?>
Y.php
<?php
$test = 'Hello World';
?>
My Expectation: Variable $test
should be accessible in X.php after the include statement
Scenario 2: Value printed in Y is used in X
X.php
<?php
include 'web/y.php';
?>
Y.php
<?php
echo 'Hello World';
?>
My Expectation: Hello World should be printed when X.php is accessed