'PHP require_once not recognised

I'm newbie on PHP and I'm not sure why the 'require_once' is not working. Both PHP files are located in the same directory and another PHP file which is the same DIR is working correctly with the same 3 lines.

 <?php
        
    
    header('Content-Type: application/json');

    $aResult = array();

    if( !isset($_POST['functionname']) ) { $aResult['error'] = 'No function name!'; }

    if( !isset($_POST['arguments']) ) { $aResult['error'] = 'No function arguments!'; }

    if( !isset($aResult['error']) ) {

        switch($_POST['functionname']) {
            case 'delete_monument':
                if( !is_array($_POST['arguments']) || (count($_POST['arguments']) < 1) ) {
                    $aResult['error'] = 'Error in arguments!';
                }
                
                else {
                    $dir = '[PRIVATE DATA]' . urldecode($_POST['arguments'][0]);

                    $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
                    $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
                    foreach($files as $file) {
                        if ($file->isDir()){
                        rmdir($file->getRealPath());
                        } 
                        else {
                            unlink($file->getRealPath());
                        }
                    }
                    rmdir($dir);

                    //Clean database
                    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php';
                    SigPlusNovoDatabaseSetup::update();
                    SigPlusNovoDatabaseSetup::populate();

        
                    $aResult['result'] = $dir;
                }              
                break;         
               
              
            default:
                $aResult['error'] = 'Not found function '.$_POST['functionname'].'!';
                break;
        }
    }
    echo json_encode($aResult);

?>

I checked other posts but nothing seems to be my problem. Can someone help me?

Thx.

Edit:

I wrote this lines at the top

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

and checked the PHP error log, but no errors are displayed :/

php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source