PHP目录不正确

I have a /controller/controller.php file that runs this code:

include('../model/model.php');
print page_load();

The model/model.php loads correctly and the page_load() function gets loaded. However, the model.php file still 'thinks' that it is in the controller directory. So if I try and do any POST actions in the model.php, it looks in the controller directory rather than the model directory.

Can I please have some advice on how to fix this?

thanks

In model.php your need set action in form with correct path to post it to your model.php

<form action="/model/model.php">
// bla-bla-input-bla-bla
</form>

You are still inside the controller page [1]. As suggested by the name the controller page simply includes the the model page. What Sergey said is partly correct. You need to to assign a more complete path to the form's action parameter. As I am sure you will see Sergey's answer does not work. This is because you need to go up one directory. This is done by including two dots that is .. before the path.

<form action="../model/model.php">

You are already including the .. in your include statement. Just use it in the same way.

Please let us know if you need more help. :-)

[1] http://php.net/manual/en/function.include.php

I think you are looking for chdir function. With it, you can change your current directory, allowing PHP to think you are in model/ folder.