I have the following script
myclass.php
<?php
$myarray = array('firstval','secondval');
class littleclass {
private $myvalue;
public function __construct() {
$myvalue = "INIT!";
}
public function setvalue() {
$myvalue = $myarray[0]; //ERROR: $myarray does not exist inside the class
}
}
?>
Is there a way to make $myarray available inside the littleclass, through simple declaration? I don't want to pass it as a parameter to the constructor if that was possible.
Additionally, I hope that you actually CAN make global variables visible to a php class in some manner, but this is my first time facing the problem so I really don't know.