我不知道这是否可能
我在两个网站上工作,我想通过 URL 将数组从一个站点传递到另一个站点
例如
$myreceivearray = http://mydomain/myscript.php
这个 myscript.php 应该返回一个数组。
再次在问题中添加一些部分
根据我试过的答案,我的 myscript.php 代码是
<?php
if (session_id() == "") session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include_once "ewcfg10.php" ?>
<?php include_once "adodb5/adodb.inc.php" ?>
<?php include_once "phpfn10.php" ?>
<?php include_once "ACCOUNTinfo.php" ?>
<?php include_once "userfn10.php" ?>
<?php
//
// Page class
//
$custompage = NULL; // Initialize page object first
class ccustompage {
// Page ID
var $PageID = 'custompage';
// Project ID
var $ProjectID = "{D5B1B389-2DCD-4664-BAD5-27C1596B8577}";
// Page object name
var $PageObjName = 'custompage';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
return $PageUrl;
}
// Message
function getMessage() {
return @$_SESSION[EW_SESSION_MESSAGE];
}
function setMessage($v) {
ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
}
function getFailureMessage() {
return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
}
function setFailureMessage($v) {
ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
}
function getSuccessMessage() {
return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
}
function setSuccessMessage($v) {
ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
}
function getWarningMessage() {
return @$_SESSION[EW_SESSION_WARNING_MESSAGE];
}
function setWarningMessage($v) {
ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $v);
}
// Show message
function ShowMessage() {
$hidden = FALSE;
$html = "";
// Message
$sMessage = $this->getMessage();
$this->Message_Showing($sMessage, "");
if ($sMessage <> "") { // Message in Session, display
if (!$hidden)
$sMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>" . $sMessage;
$html .= "<div class=\"alert alert-success ewSuccess\">" . $sMessage . "</div>";
$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
}
// Warning message
$sWarningMessage = $this->getWarningMessage();
$this->Message_Showing($sWarningMessage, "warning");
if ($sWarningMessage <> "") { // Message in Session, display
if (!$hidden)
$sWarningMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>" . $sWarningMessage;
$html .= "<div class=\"alert alert-warning ewWarning\">" . $sWarningMessage . "</div>";
$_SESSION[EW_SESSION_WARNING_MESSAGE] = ""; // Clear message in Session
}
// Success message
$sSuccessMessage = $this->getSuccessMessage();
$this->Message_Showing($sSuccessMessage, "success");
if ($sSuccessMessage <> "") { // Message in Session, display
if (!$hidden)
$sSuccessMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>" . $sSuccessMessage;
$html .= "<div class=\"alert alert-success ewSuccess\">" . $sSuccessMessage . "</div>";
$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
}
// Failure message
$sErrorMessage = $this->getFailureMessage();
$this->Message_Showing($sErrorMessage, "failure");
if ($sErrorMessage <> "") { // Message in Session, display
if (!$hidden)
$sErrorMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>" . $sErrorMessage;
$html .= "<div class=\"alert alert-error ewError\">" . $sErrorMessage . "</div>";
$_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
}
echo "<table class=\"ewStdTable\"><tr><td><div class=\"ewMessageDialog\"" . (($hidden) ? " style=\"display: none;\"" : "") . ">" . $html . "</div></td></tr></table>";
}
//
// Page class constructor
//
function __construct() {
global $conn, $Language, $UserAgent;
// User agent
$UserAgent = ew_UserAgent();
$GLOBALS["Page"] = &$this;
// Language object
if (!isset($Language)) $Language = new cLanguage();
// User table object (ACCOUNT)
if (!isset($GLOBALS["ACCOUNT"])) $GLOBALS["ACCOUNT"] = new cACCOUNT;
// Page ID
if (!defined("EW_PAGE_ID"))
define("EW_PAGE_ID", 'custompage', TRUE);
// Start timer
if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer();
// Open connection
if (!isset($conn)) $conn = ew_Connect();
}
//
// Page_Init
//
function Page_Init() {
global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
// Security
$Security = new cAdvancedSecurity();
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
// Uncomment codes below for security
//if (!$Security->IsLoggedIn())
// $this->Page_Terminate("login.php");
if (@$_GET["export"] <> "")
$gsExport = $_GET["export"]; // Get export parameter, used in header
$this->CurrentAction = (@$_GET["a"] <> "") ? $_GET["a"] : @$_POST["a_list"]; // Set up curent action
global $gbOldSkipHeaderFooter, $gbSkipHeaderFooter;
$gbOldSkipHeaderFooter = $gbSkipHeaderFooter;
$gbSkipHeaderFooter = TRUE;
// Global Page Loading event (in userfn*.php)
Page_Loading();
// Page Load event
$this->Page_Load();
}
//
// Page_Terminate
//
function Page_Terminate($url = "") {
global $conn;
global $gbOldSkipHeaderFooter, $gbSkipHeaderFooter;
$gbSkipHeaderFooter = $gbOldSkipHeaderFooter;
// Page Unload event
$this->Page_Unload();
// Global Page Unloaded event (in userfn*.php)
Page_Unloaded();
$this->Page_Redirecting($url);
// Close connection
$conn->Close();
// Go to URL if specified
if ($url <> "") {
if (!EW_DEBUG_ENABLED && ob_get_length())
ob_end_clean();
header("Location: " . $url);
}
}
//
// Page main
//
function Page_Main() {
global $Security, $Language;
//$this->setSuccessMessage("Welcome " . CurrentUserName());
// Put your custom codes here
}
// Page Load event
function Page_Load() {
//echo "Page Load";
}
// Page Unload event
function Page_Unload() {
//echo "Page Unload";
}
// Page Redirecting event
function Page_Redirecting(&$url) {
// Example:
//$url = "your URL";
}
// Message Showing event
// $type = ''|'success'|'failure'
function Message_Showing(&$msg, $type) {
// Example:
//if ($type == 'success') $msg = "your success message";
}
}
?>
<?php ew_Header(FALSE) ?>
<?php
// Create page object
if (!isset($custompage)) $custompage = new ccustompage();
// Page init
$custompage->Page_Init();
// Page main
$custompage->Page_Main();
?>
<?php include_once "header.php" ?>
<?php
$custompage->ShowMessage();
?>
<!-- Put your custom html here -->
<?PHP
$myarray = array(1,2,3,4,5);
echo json_encode($myarray);
?>
<?php include_once "footer.php" ?><?php
$custompage->Page_Terminate();
?>
我无法更改所有代码,因为我必须集成到我的旧项目中。在最后 7 行中,我输入了代码,当我打开此页面时,它仅输出为 [1,2,3,4,5],当我尝试将其作为
<?PHP
$myreceivearray = json_decode(file_get_contents('http://mydomain/blankpage.php'));
print_r($myreceivearray);
?>
我没有在这里得到数组。
请帮我。