Hi,
> If you have an array assigned to a variable, you access elements of it with
> [].
>
> $foo = array('a', 'b', 'c');
>
> print $foo[0]; // gives 'a'
>
> $bar = array('a' => 'hello', 'b' => 'world');
>
> print $foo['b']; // gives 'world'
I know that.
I had my class written as:
----------------------------------------------------------------
class returnConfigParams
{
var $a;
var $b;
var $c;
var $d;
// function that get the database parameters from "properties.php"
function getMySQLParams()
{
include($_SERVER['DOCUMENT_ROOT']."/properties.php");
$mysql_parameters = array(0 => $a, 1 => $b, 2 => $c, 3 => $d);
return($mysql_parameters);
}
}
?>
----------------------------------------------------------------
and i got the array values with:
$params_file = New returnConfigParams;
$params = $params_file->getMySQLParams();
values were $params[0], etc...
everything was fine.
then, someone suggested i might write it like this, so i can call it
with returnConfigParams::getMySQLParams();
----------------------------------------------------------------
class returnConfigParams
{
private static $instance = NULL;
private function __construct() {
}
// function that get the database parameters from "properties.php"
public static function getMySQLParams() {
if (!self::$instance)
{
/*** set this to the correct path and add some error checking ***/
include($_SERVER['DOCUMENT_ROOT']."/properties.php");
self::$instance = array($a, $b, $c, $d);
}
return self::$instance;
}
private function __clone(){
}
}
?>
----------------------------------------------------------------
This way i can't get the array elements.
I've tried
$params = returnConfigParams::getMySQLParams();
but no good.
And that's the story.
Cheers,
AR
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php