...I can't get it to work.π
This should output:
...And if you drop the code above into a PHP file and load it up in a browser, you will see that output. But if you drop that same code into a box in CF, you just get:
Form HTML, On submit before, On submit after, doesn't seem to matter. Same output. Took me a while to drill down and isolate this problem. I don't know if it's a CF bug or a J! bug (or some sort of "security feature"π), but I'm wondering if anyone has a workaround. I'll keep trying things.
FYI, I need this functionality because I'm trying to define variables for a file that I will include, containing a big ol' API wrapper class. In CF, I can't get the wrapper class to see the variables.
Ideas?
Thanks!
<?php
$test = 'Success!';
class TestClass {
public function __construct() {
global $test;
echo "var: " . $test;
}
}
$dummyInstance = new TestClass();
?>
This should output:
var: Success!
...And if you drop the code above into a PHP file and load it up in a browser, you will see that output. But if you drop that same code into a box in CF, you just get:
var:
Form HTML, On submit before, On submit after, doesn't seem to matter. Same output. Took me a while to drill down and isolate this problem. I don't know if it's a CF bug or a J! bug (or some sort of "security feature"π), but I'm wondering if anyone has a workaround. I'll keep trying things.
FYI, I need this functionality because I'm trying to define variables for a file that I will include, containing a big ol' API wrapper class. In CF, I can't get the wrapper class to see the variables.
Ideas?
Thanks!
Hi yorb,
Try:
Bob
Try:
<?php
global $test;
$test = 'Success!';
class TestClass {
public function __construct() {
global $test;
echo "var: " . $test;
}
}
$dummyInstance = new TestClass();
?>
Bob
Thanks, I JUST figured that out haha. Feel free to delete the thread if you find it silly and useless.π
It occurred to me to try it inside a regular function, and when THAT didn't work I knew something was up. Declaring it global before the definition fixed it. Why does CF require that? Or rather, why can I get away without using it outside of CF?
It occurred to me to try it inside a regular function, and when THAT didn't work I knew something was up. Declaring it global before the definition fixed it. Why does CF require that? Or rather, why can I get away without using it outside of CF?
This topic is locked and no more replies can be posted.