Hello I am having trouble accessing a multidimensional array that is on a separate php page. Example on index.php:
include 'scripts/test.php';
echo $test[1][1];
on test.php:
$test = array
(
array("One", "Two"),
array("Three", "Four")
);
Wanted Result:
Four
This works fine when I have the array on the same page as the echo, also the route is correct because this works fine when I'm using a normal array on the same test.php file.
Did you turn error reporting on? Does the include work? The code itself should work so I guess your problem is the include
You could also use $_SERVER['DOCUMENT_ROOT']
to be absolutely sure to include the right file:
<?php
include($_SERVER['DOCUMENT_ROOT']."/scripts/test.php");
doit();
?>
With your code your folder structure should look like this:
/scripts/test.php
/index.php
But first of all put this at the top of your index.php
error_reporting(E_ALL);
ini_set('display_errors', '1');
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加