relative path - How to use a variable in PHP file from another PHP file with include or require? -


check out directory http://imgur.com/skuxjm9 , simple. wanted call variable nuclear_test2.php nuclear_test.php

//i have unsuccessfully tried following calls stated below: //include_once("../test/nuclear_test2.php"); //include_once("nuclear_test2.php"); //include_once("./test/nuclear_test2.php"); //require_once("./nuclear_test2.php"); 

nuclear_test.php

<?php  require "nuclear_test2.php";   function acheckreturner() {         echo   " ?" .  $check; }     acheckreturner(); ?> 

nuclear_test2.php

<?php     $check = " ooooooooo"; ?> 

the problem not include or require. problem $check not defined inside acheckreturner function.

<?php  require "nuclear_test2.php";  function acheckreturner() {     echo   " ?" .  $check; // $check undefined in scope } acheckreturner(); ?> 

you can use passing argument acheckreturner function.

<?php  require "nuclear_test2.php";  function acheckreturner($check) {     echo   " ?" .  $check; }  acheckreturner($check); // $check nuclear_test2.php ?> 

the php documentation on variable scope may helpful.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -