class - PHP Require file inside Static Method -


in class i've got method, includes diffrent files based on input.

the files included correctly => var_dump shows "true".

but!! if want access included variable, tells me, it's not defined....

the included file:

<?php $cpucooler = array( array(     "name" => "boxed cpu lüfter",     "sockel" => "alle",     "leistung" => 20,     "rpm" => 2000,     "preis" => 0 )); ?> 

the class method:

/**  * hardware classes  * @param string $type hardware type  * @return array  */ public static function gethardware($type) {     switch ($type) {         case 'cpucooler':             require_once "hardware/cpucooler.php";             var_dump($cpucooler); // undefined variable...             return $cpucooler;             break;     } } 

hope can me

file correctly included, problem was, used

require_once $file; return $cpucooler; 

instead of

require $file; return $cpucooler; 

don't know why...


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -