error_reporting(E_ALL);
ini_set('display_errors','1');
if (file_exists('/../_config.php')) {
$f = fopen('/../_config.php', 'w') or die($php_errormsg);
fwrite($f, '<?php');
fclose($f);
}
else {
echo 'file doesnt exist';
}
결과 :아무것도fopen이 파일에 쓰지 않습니까?
은 내가 _config.php 파일을 확인하고 비어 있습니다. <?php
을 포함해야합니다.
오류가 없습니다. & 코드가 전혀 죽지 않습니다.
권한 관련 문제입니까?
error_reporting(E_ALL);
ini_set('display_errors','1');
$configFile = __DIR__ . '/../config.php';
echo $configFile, "\n";
if (file_exists($configFile)) {
$f = fopen($configFile, 'w') or die('cannot open file');
fwrite($f, '<?php');
fclose($f);
}
else {
echo 'file doesnt exist', "\n";
}
대신 __DIR__
당신이 dirname(__FILE__)
를 사용할 수
AFAIK'/../_ config.php' _cannot_ exist (한 수준 _ 루트 _ 경로보다) – Wrikken
경로에 텍스트를 추가하여 테스트했는데 '파일이 존재하지 않습니다'라는 메시지가 나타납니다. –
파일 경로가 확실히 문제를 일으킬 것입니다. '/../_ config.php'는 "루트에서 시작하여 한 레벨 위로 올라가서'_config.php'를 찾습니다. –