调用索引.php从另一个索引.php不同的目录


call index.php from another index.php of different directory

/school
/teacher
  index.php
/student
  index.php

如何从teacher/index.php拨打student/index.php

在你的

老师/索引中.php写

header("Location: ../student/index.php"); // this is incase you want to go to that page
require_once('../student/index.php'); // incase you want to include that file
require '../student/index.php';

这将"调用"脚本。如果脚本具有返回值,则只需在 require 语句的左侧创建赋值语句即可。

$ret = require '../student/index.php';

在你的teacher/index.php顶部使用此代码

header("Location: ../student/index.php");
您还可以

使用pecl_http(如果可用(和函数http_redirect。

http://php.net/manual/en/function.http-redirect.php