Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

PHP class: Global variable as property in class -


i have global variable outside class = $mynumber;


how declare property in myclass?
every method in class, do:

class myclass() {      private function foo() {          $privatenumber = $globals['mynumber'];     }  } 



want this

class myclass() {      //what goes here?     var $classnumber = ???//the global $mynumber;      private function foo() {          $privatenumber = $this->classnumber;     }  } 



edit: want create variable based on global $mynumber but
modified before using in methods

something like: var $classnumber = global $mynumber + 100;

you don't want doing this, it's going nightmare debug, seems possible. key part assign reference in constructor.

$globals = array(     'mynumber' => 1 );  class foo {     protected $glob;      public function __construct() {         global $globals;         $this->glob =& $globals;     }      public function getglob() {         return $this->glob['mynumber'];     } }  $f = new foo;  echo $f->getglob() . "\n"; $globals['mynumber'] = 2; echo $f->getglob() . "\n"; 

the output

1 2 

which indicates it's being assigned reference, not value.

as said, nightmare debug, shouldn't this. have read through wikipedia article on encapsulation; basically, object should ideally manage own data , methods in data modified; public properties generally, imho, bad idea.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -