Hi,
I am stuck with a silly problem which I cant resolve. Please look at the example:
settings.php
[code=php]
<?php
define('VALUE_S TRING', 'This is my string');
$VALUE_ARRAY = array('This', 'is', 'my', 'array');
?>
[/code]
values.class.ph p
[code=php]
<?php
Class Values
{
/* Here I have some constructor */
public function getValues() {
error_log("Firs t: " . VALUE_STRING);
error_log("Seco nd: " . implode(', ', $VALUE_ARRAY));
}
?>
[/code]
index.php
[code=php]
<?php
$values = new Values();
$values->getValues();
?>
[/code]
When I execute index.php I get the following in the error log:
Does anyone know why I cant get the array values, but I can get the constant?
Cheers,
Pimmy
I am stuck with a silly problem which I cant resolve. Please look at the example:
settings.php
[code=php]
<?php
define('VALUE_S TRING', 'This is my string');
$VALUE_ARRAY = array('This', 'is', 'my', 'array');
?>
[/code]
values.class.ph p
[code=php]
<?php
Class Values
{
/* Here I have some constructor */
public function getValues() {
error_log("Firs t: " . VALUE_STRING);
error_log("Seco nd: " . implode(', ', $VALUE_ARRAY));
}
?>
[/code]
index.php
[code=php]
<?php
$values = new Values();
$values->getValues();
?>
[/code]
When I execute index.php I get the following in the error log:
Code:
[Fri Nov 02 11:57:59 2007] [error] [client 9.196.182.69] First: This is my string [Fri Nov 02 11:57:59 2007] [error] [client 9.196.182.69] PHP Notice: Undefined variable: VALUE_ARRAY in /usr/local/apache/htdocs/values.class.php on line 9 [Fri Nov 02 11:57:59 2007] [error] [client 9.196.182.69] PHP Warning: implode() [<a href='function.implode'>function.implode</a>]: Bad arguments. in /usr/local/apache/htdocs/values.class.php on line 9 [Fri Nov 02 11:57:59 2007] [error] [client 9.196.182.69] Second:
Cheers,
Pimmy
Comment