Passing value from get_option to a JavaScript file

This is hard for me to explain so I hope you’ll bear with me on this…

I have 2 files: func.php and sizer.php.

func.php has some miscellaneous variables, a constant used for addressing, and a special variable that is assigned a function call (get_option(‘users_can_register’) that I need to make an eventual JavaScript conditional used to see if users can register.

sizer.php has some various PHP echos used to output some JavaScript (so in essence, it’s a JavaScript file with a PHP extension). I included func.php in this file to access the variables, constant, and special variable mentioned above as it pertains to the other JavaScript contained in this file…

The problem that I’m running into here is how the JavaScript in sizer.php is accessing everything from func.php. It seems to access the constant perfectly fine but it’s breaking with the special variable and I have no idea why.

So inside of func.php, I have the following code:

	$siteurl = ($_SERVER["HTTP_HOST"] == 'localhost') ? 'http://localhost/websites/blah' : '';
	define('ABSPATH2', $siteurl);
	$test = get_option('users_can_register');

…and inside of sizer.php, I have the following:

	include '../func.php';
	echo 'var register = "'.$test.'";';
	echo 'var dir = "'.ABSPATH2.'/wp-content/themes/blah/c/";

Firefox with Firebug is indicating that there’s a missing semi-colon. It’s also telling me that I’m making a call to an undefined function from within func.php. I have no idea why or what’s going on here because when I echo $test, it outputs perfectly fine with the right value(s) but when I try to use $test from within sizer.php, it breaks.

Could someone help me understand what I’m doing wrong here? Why does the constant ABSPATH2 work flawlessly but not $test? :frowning:

Sorry guys / gals… I think I figured this one out. I was over-thinking things.