variables across subdomains


I’m fairly new to php development and am in the process of building my first php content managed web site.

I have a main domain which contains most of the php function files ( all included ) and the page templates ( also included ), but i also have a subdomain of this domain that i wish to allow to use the same files.

I have an index.php file at both locations which includes all the function files and adds some variables unique to each domain. This all works fine on the main domain and variables etc are shared between all the includes correctly. However, i have just got round to creating the index file for the sub domain and have found two problems.

Firstly, any variables i set in index.php of the subdomain cannot be found in any of the files i include from the main domain.

Secondly, when i try to call a function from the subdomain that is contained in one of the included files from the main domain the error "Fatal error: Call to undefined function: fn_checkstructureidexists() " appears.

Is the loss of variables and functions across subdomains a security/sandboxing issue? Is there anyway around this? Its getting very frustrating cos it just doesnt make any sence.

Please help / advise! Many thanks!

I think you are probably looking at a permissions issue.

First of all the variables are not “Domain Dependant”. They do have limitations though. (Please see

If you are including functions and you are getting an CALL TO UNDEFINED FUNCTION, then it’s likely NOT getting included. Again reasons might be permissions.

Check to see that your error reporting is not at such a level to NOT report the error (in php.ini), (i.e. set it, at least temporarily to E_ALL) and see what the error .

Might also change the INCLUDE() to REQUIRE(). Include errors might not show, however if you cannot get the file using REQUIRE() then execution halts (thus a fatal error). All this, again, is to verify the permissions to the file.

Good luck and let us know the results.

Sponsor our Newsletter | Privacy Policy | Terms of Service