您好我目前正在嘗試在PHP腳本中包含一些函數,但不斷收到一個錯誤,我真的很難找出答案。我已經通過權限和其他一些東西,但無濟於事。試圖包含文件時需要()php錯誤
這裏是我的php - 其中的代碼只是爲了測試一些東西,我不認爲它不影響'require()'調用,但我可能顯然是錯的。
#!/usr/bin/env php
<?php
require(__DIR__ . "/../includes/config.php");
if ($argc !=2)
{
print("Please specify file path \n");
return -1;
}
$file = $argv[1];
print($file);
if (!file_exists($file))
{
print("Error: file " . $file . " doesn't exist\n");
//return -1;
}
if (is_writable($file))
{
$copy = 'copy1.txt';
$handle = file_get_contents($file);
file_put_contents($copy, $handle);
}
else
{
echo "The file $filename is not writable \n";
}
end;
$test = query("INSERT INTO `pset8`.`places` (
`id` ,
`country_code` ,
`postal_code` ,
`place_name` ,
`admin_name1` ,
`admin_code1` ,
`admin_name2` ,
`admin_code2` ,
`admin_name3` ,
`admin_code3` ,
`latitude` ,
`longitude` ,
`accuracy`
)
VALUES (
'2', '', '', '', '', '', '', '', '', '', '', '', ''
)");
?>
這裏是錯誤:
PHP Warning: require(../vendor/library50-php-5/CS50/CS50.php): failed to open stream: No such file or directory in /home/ubuntu/workspace/pset8/includes/config.php on line 20
PHP Stack trace:
PHP 1. {main}() /home/ubuntu/workspace/pset8/bin/import:0
PHP 2. require() /home/ubuntu/workspace/pset8/bin/import:3
Warning: require(../vendor/library50-php-5/CS50/CS50.php): failed to open stream: No such file or directory in /home/ubuntu/workspace/pset8/includes/config.php on line 20
Call Stack:
0.0002 235656 1. {main}() /home/ubuntu/workspace/pset8/bin/import:0
0.0022 238328 2. require('/home/ubuntu/workspace/pset8/includes/config.php') /home/ubuntu/workspace/pset8/bin/import:3
PHP Fatal error: require(): Failed opening required '../vendor/library50-php-5/CS50/CS50.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ubuntu/workspace/pset8/includes/config.php on line 20
PHP Stack trace:
PHP 1. {main}() /home/ubuntu/workspace/pset8/bin/import:0
PHP 2. require() /home/ubuntu/workspace/pset8/bin/import:3
Fatal error: require(): Failed opening required '../vendor/library50-php-5/CS50/CS50.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ubuntu/workspace/pset8/includes/config.php on line 20
Call Stack:
0.0002 235656 1. {main}() /home/ubuntu/workspace/pset8/bin/import:0
0.0022 238328 2. require('/home/ubuntu/workspace/pset8/includes/config.php') /home/ubuntu/workspace/pset8/bin/import:3
提前感謝!
文件夾結構是什麼樣的?與'includes'有關的文件夾'vendor'在哪裏? – Qirel
基本上,文件結構已經預先設置爲CS50的pset的一部分。供應商文件夾與包含的級別相同,並具有相同的父級 - pset8。它設置在cloud9 IDE上。希望有幫助嗎? – Stoob
從我可以讀取的錯誤中,他們發生在嘗試訪問'config.php'腳本時,並且您嘗試包含文件'CS50.php' - 這是正確的嗎? – Qirel