0

I have a php file called Route.php which is located on:

/var/www/api/src/fra/custom/Action

and the file I want to include is in:

/var/www/api/src/fra/custom/

So what I have inside route php is an absolute path to the two php file I want to include:

<?php

 include '/var/www/api/src/frapi/custom/myneighborlists.php';
 include '/var/www/api/src/frapi/custom/mynodes.php';

............
...........

?>

These two file has an array of large amount of size that I want to use in Route.php. When I do vardump($global) it just returns NULL. What am I missing here?

UPDATE:

I did an echo on the included file and it prints something, so therefore it is included.. however I can't get access that array... when I do a vardump on the array, it just returns NULL!

I did add a global $myarray inside the function in which I want to access the array from the other php file

Sample myneighborlists.php:

<?php

$myarray = array(
1=> array(3351=>179),
2=> array(3264=>172, 3471=>139),
3=> array(3467=>226),
4=> array(3309=>211, 3469=>227),
5=> array(3315=>364, 3316=>144, 3469=>153),
6=> array(3305=>273, 3309=>171),
7=> array(3267=>624, 3354=>465, 3424=>411, 3437=>632),
8=> array(3302=>655, 3467=>212),
9=> array(3305=>216, 3306=>148, 3465=>505),
10=> array(3271=>273, 3472=>254),
11=> array(3347=>273, 3468=>262),
12=> array(3310=>237, 3315=>237));

?>
13
  • try doing include('../myfile.php') instead of using an absolute path Commented Mar 5, 2011 at 3:02
  • test that the files are getting included correctly. maybe echo something out in your two includes. Commented Mar 5, 2011 at 3:08
  • 1
    Also, I believe you want to do var_dump( $GLOBALS ); to dump the current global variable table. Not sure if that was just quick typing on your behalf. Commented Mar 5, 2011 at 3:11
  • 1
    how are you executing Route.php is it part of another php script? Commented Mar 5, 2011 at 3:13
  • 1
    doing a var_dump global I saw that ["myarray"]=> &NULL }, why is this? it is not null.. it has like 800 entries in it Commented Mar 5, 2011 at 3:23

2 Answers 2

2
A better approach

define('APP_DIR', '/var/www/api/src/fra/custom');
include(APP_DIR.'/mynodes.php');
Sign up to request clarification or add additional context in comments.

Comments

0

set_include_path("/var/www/api/src/fra/custom");

Then include your files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.