I know that my question is elementary in php, but I can't find any resource to solve it. For sake of simplicity, I brief my problem with a simple code.
I want to separate php and html files. So I creates a file named: view.php
<?php
global $var;
?>
<html>
<body>
<p>
Variable value is:
<?php $var ?>
</p>
</body>
</html>
I have another file that uses this template: call.php
<?php
function call(){
global $var;
$var='111';
require_once 'view.php';
}
call();
The problem is that the variable does not pass from call.php to view.php.
This code prints a simple html as follow:
Variable value is:
As you can see, the variable value has not printed here.
Please assume that the view.php is a large html template that would be populated with numbers of variables. So, I want to controller and view be as separated as possible.(I don't want to echo html directly)
how can I do that?
I tested the above code, but without success