我有一个引导脚本。
bootstrap.php中
<?php
$bootstrapFoo = 'foo';
和主要脚本。
main.php
<?php
require_once 'bootstrap.php';
print $bootstrapFoo; // this is working
// I include a subscript
include_once 'subscript.php';
subscript.php
<?php
print $bootstrapFoo; // this is NOT working.
我的解决方案:
<?php
global $bootstrapFoo;
print $bootstrapFoo; // now that's working
这是正确的方法吗?
ps:找不到重复项。