[英]How can I get the echo output of a php script from a php script on my server?
I am working on a backend for my school's website and I have run into a problem.我正在为我学校的网站开发后端,但遇到了问题。 I am powering a blog on the homepage and for teacher websites and have setup an SSO system between the two.我正在为主页和教师网站上的博客提供支持,并在两者之间设置了 SSO 系统。 I am linking into it for a unified admin panel that I am making to manage them and a dynamic calendar via a php script that is placed inside of the homepage's blog directory.我正在链接到一个统一的管理面板,我正在通过放置在主页博客目录中的 php 脚本管理它们和动态日历。 It doesn't work if it is not in the blog's directory My problem is that it echos a JSON array of the current logged in user and I am having trouble getting the json array from the admin panel that I am developing.如果它不在博客的目录中,它就不起作用 我的问题是它回显了当前登录用户的 JSON 数组,我无法从我正在开发的管理面板获取 json 数组。 Here is the code of the script in the blog's directory:这是博客目录中脚本的代码:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
include 'wp-blog-header.php';
global $current_user;
get_currentuserinfo();
if (is_user_logged_in()) {
$userInfo = ((array) $current_user);
$loggedIn = true;
} else {
$userInfo = null;
$loggedIn = false;
}
echo json_encode(array(
'loggedIn' => $loggedIn,
'userInfo' => $userInfo
));
?>
Here is the code of the current script in the admin panel:这是管理面板中当前脚本的代码:
<?php
error_reporting( E_ALL );
ini_set('display_errors', 'on');
$response = file_get_contents(dirname(dirname(dirname(__FILE__))) . '/homepage-blog/controlPanelUserCommunicate.php');
var_dump($response);
?>
Here is the output of current script in the admin panel:这是管理面板中当前脚本的输出:
string(374) " $loggedIn, 'userInfo' => $userInfo )); ?>"
you accessing the file directly, so you gets contents, its not being run though the web server to process the php你直接访问文件,所以你得到内容,它不是通过网络服务器运行来处理 php
you probably want你可能想要
$response = file_get_contents('http://SITE/controlPanelUserCommunicate.php');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.