I'm trying to learn PHP by following the PHP manual, but one of the examples doesn't seem to work for me when I tried it. What I am doing is attempting to import a defined variable to another PHP file and then doing a simple echo of the variable name and value like such: Code: variables.php: define("MY_VERSION", 1.1); printoff.php: obstart(); include './variables.php'; ob_end_clean(); echo "MY_VERSION"; //should print MY_VERSION echo "My_version"; //should print 1.1 What am I doing wrong here?
Can't import defined variables?
3
I'm trying to learn PHP by following the PHP manual, but one of the examples doesn't seem to work for me when I tried it. What I am doing is attempting to import a defined variable to another PHP file and then doing a simple echo of the variable name and value like such:
What am I doing wrong here?
Should note the error I get is "Use of undefined constant"
Code:
variables.php:
define("MY_VERSION", 1.1);
printoff.php:
obstart();
include './variables.php';
ob_end_clean();
echo "MY_VERSION"; //should print MY_VERSION
echo "My_version"; //should print 1.1 Should note the error I get is "Use of undefined constant"
- IronMike
- [1] reply
- Brandon Tanner
- Ice Berg Banned
Next Topics on Trending Feed
-
3