为什么我的数组在我的PHP包含文件中不可见?

时间:2014-05-12 17:37:54

标签: php

我有一个主页面,我在其中声明一个数组添加值:

<?php
  $items = array();
  $items[] = "one";
  $items[] = "two";
  $items[] = "three";
  include("http://mydomain.net/process.php);
?>

process.php文件中,我有:

<?php
  foreach($items as $item) {
    print $item;
  }
?>

问题是没有任何东西被打印出来。当我将数组的赋值移动到process.php时,一切都按预期工作。我觉得奇怪的是我在另一个网站上做了同样的事情,并且它有效。我在这里缺少什么?

1 个答案:

答案 0 :(得分:3)

如果您想传递网址,则必须包含完整网址(包括http://)。改为给它提供文件的路径。

include("/path/to/file/process.php");

请参阅手册中的example 3

相关问题