Reputation: 1
I want to configure Composer autoload but it seems to work not correctly. PHP doesn't see included variables from other files.
a1.php
<?php
echo "Test";
$a = "Hello";
a2.php
<?php
require __DIR__ . '/../vendor/autoload.php';
echo $a;
So I it comes to
Test
PHP Notice: Undefined variable:
I can't understand, why it can see "Test" but it can't see my variable $a. But if I try the same thing without Composer (with include or require), it works well.
Upvotes: 0
Views: 234
Reputation: 927
Autoload is for classes only, it does not incluse variables.
You should try using globals, or better : avoid using variables defined in a différent file/scope
Upvotes: 2