I am trying to pass a variable to a vendor file like so:
echo '>'.$foo;
App::import('Vendor', 'foo'.DS.'bar');
Inside my vendor file I also have echo '>'.$foo;
The first time before I load the vendor file it echos $foo just fine. The second time inside the vendor file it tells me $foo is not defined.
How can I pass the variable to the vendor file?
Wouldn’t you expect this behaviour?
This is because your
$foovariable is not defined inside theApp::import()method, which calls the PHPincludestatement.How about just using
includedirectly? Or creating a class in the file you’re including and instantiating it?