mysqli - Can you define class variables from within a class method in PHP? -



mysqli - Can you define class variables from within a class method in PHP? -

i want pull info file files table, table's construction might change.

so, i'd pull field names table , utilize them generate class variables contain information, store selected info them.

is possible?

sample

<?php class testclass { public $property1; public function method1() { $this->property1 = '1'; $this->property2 = '2'; } } $t = new testclass(); $t->method1(); print( '<pre>' ); print_r( $t ); print( '</pre>' ); ?>

output

testclass object ( [property1] => 1 [property2] => 2 )

as can see, property wasn't defined created assigning using reference $this. yes, can define class variable within class method.

php mysqli

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -