Variable scope and functions in view |
[eluser]Leo78[/eluser]
Hey, First of all, I know that the following thing it's unacceptable, but I don't have any choice, so don't tell me about it. I tried to write this simple thing in the view (taken from PHP.net just for the example): Code: // view_test.php The controller is simple too: Code: class Draw extends MY_Controller { The result should be $b = 3, but $b = 2 and it doesn't refer to the `global` attitude, why does it happen and what can I do to get it works? Thank you!
[eluser]solid9[/eluser]
Well, It works for me. http://coder9.com/php/global_var.php What PHP version you are using?
[eluser]Leo78[/eluser]
[quote author="solid9" date="1350720120"]Well, It works for me. http://coder9.com/php/global_var.php What PHP version you are using? [/quote] I'm talking about test it in view file (of CodeIgniter).
[eluser]Aken[/eluser]
What are you actually trying to do? There has to be a far better solution than defining a function in the middle of your view (which is ugly).
[eluser]Leo78[/eluser]
[quote author="Aken" date="1350723355"]What are you actually trying to do? There has to be a far better solution than defining a function in the middle of your view (which is ugly).[/quote] You are absolutely right, the problem is that there is nothing to do. I'm trying to integrate a really ugly-code system which contains something like 20 files. |
Welcome Guest, Not a member yet? Register Sign In |