我手动运行该脚本,一切正常,
$container = require '../config/bootstrap.php';
try {
$test = $container->get(Test::class);
$test->run();
}
catch(\Exception $e) {
echo $e->getMessage() . "\n";
die;
}
但是当我从另一个文件夹中调用该文件时,如下所示:
$script = __DIR__ .'/folder/test-service.php';
$output = shell_exec('php '.$script);
var_dump($output);
我收到以下错误:
致命错误:require():在第13行的/anotherFolder/folder/test-service.php中打开所需的'../config/bootstrap.php'(include_path =':')失败
之后,我收到了很多文件不存在的错误。
bootstrap.php包含PHP-DI的类映射
要求'../ vendor / autoload.php';
use DI\ContainerBuilder;
$containerBuilder = new ContainerBuilder;
$containerBuilder->addDefinitions(__DIR__ . '/config.php');
$container = $containerBuilder->build();
return $container;
答案 0 :(得分:0)
String[] code = {"a", "b","c", "d", "e"};
String letters=input.nextLine();
for (int i=0;i<code.length;i++) {
if (letters.equals(code[i])) {
System.out.print(i);
}
}
指令与您当前的目录相关。
您可以使用require