在文件夹中包含一次azure web php

I try include

in folder wwwroot/sample/printsample.php

I write this code

  <?php
            include_once("testerror/warning.php");
  ?>

and

in folder wwwroot/testerror/warning.php

I write this code

<?php

    echo "Hello World";

?>

When I try to access via web site example.com/sample/printsample.php, I get result is nothing.

But When I include in full path in include_once in sample/printsample.php

like this

<?php
   include_once("D:\home\site\wwwroot\useblockscript\testerror\warning.php");
?>

I get the result in web print "Hello World".

What wrong with it?

Look the script is located in D:\home\site\wwwroot. So it looks for relative path. That should be D:\home\site\wwwroot\testerror\warning.php

This is some excerpt from $_SERVER

[SCRIPT_FILENAME] => D:\home\site\wwwroot\useblockscript\test.php
[REQUEST_URI] => /useblockscript/test.php
[PATH_TRANSLATED] => D:\home\site\wwwroot\useblockscript\test.php
[DOCUMENT_ROOT] => D:\home\site\wwwroot
[APPL_PHYSICAL_PATH] => D:\home\site\wwwroot\
[HTTP_X_ORIGINAL_URL] => /useblockscript/test.php
[PHP_SELF] => /useblockscript/test.php

You can try like this

include_once ($_SERVER['DOCUMENT_ROOT']."testerror/warning.php");

The reason its failing because you haven't gave and absolute include path, so its searching (relative path) in the printsample.php file path ie " wwwroot/sample".