knowNothing Posted October 12, 2006 Share Posted October 12, 2006 Lets say I've got a variable named $myvar in an included file inc.php. If I want to use that variable in a function thats nested multiple times, must I pass it through explicity all the way down to the function that will use it? In this case, I do not want to set it as a global. And I'm not looking to use a class. Is this the only way to do it? Or am I missing something that's gonna make me feel retarded? Also, is there some kind of advanced variable scope tutorial out there? At least more advanced than all the basic ones I keep reading?[code]<?php include ('inc.php'); function myfunc1($myvar) { function myfunc2($myvar) { function myfunc3($myvar) { echo $myvar; } } }?>[/code] Quote Link to comment Share on other sites More sharing options...
dayo Posted October 12, 2006 Share Posted October 12, 2006 Some help please, I have a similar issue (first post). I am trying to modify some files that have the following simplified structure[code]<?phpinclude 'a.inc';include 'b.inc';?>a.inc has the following struture<?php"A form for user input"include 'A1.inc';include 'A2.inc';?>A1.inc has the following struture<?phpfunction 1 {$x = "Value from user input form"}?>A2.inc has the following struture<?phpfunction 2 {$y = $x + 1}include 'A2_1.inc';?>A2_1.inc has the following struture<table><tr><td>"The value of $y"</td></tr></table>[/code]The files are a bit more complicated than this (Gallery2 photo display software) but this is the basic structure. I am struggling to get "The value of $y". Any tips anyone... or clues on where I could go for suggestions??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.