joblo
(Joe)
1
I have to port old (only partly object oriented) code to Yii.
There are some libs that uses a lot of global vars in functions.
I want to include these libs inside a view.
Now I have detected that the keyword ‘global’ doesn’t work in a view or component files (controller …)
It’s easy to reproduce - put this code into a view file.
$a = 1;
function test(){
global $a;
die("a=$a");
}
test();
will display: a=
not the expected a=1
Any explanation/solutions for this strange behavior?
mikl
(Mike)
2
When you declare $a on top of the view file, you’re not in the global scope. So just try:
global $a=1;
joblo
(Joe)
3
Thanks, that helps 
But seems to be a hard work to migrate:
checking hundreds of variables if they are known in a function or not 
If I had more time I would rewrite the project in ‘real Yii’…
mikl
(Mike)
4
You should include this libs in your index.php instead. Then you are in global scope and all functions should work just like in your legacy app.
joblo
(Joe)
5
Yes I did this on testing, but there are to much libraries.
I don’t want to load all on every request independent of the action I want to execute.
The old code is based on the modular concept of the Fusebox where the libs are loaded selective.
Complete rewriting the code will be the best…