pedrobcabral Posted September 26, 2006 Share Posted September 26, 2006 I'm getting stucked with the following:[code]<?phpclass something {var $var;__construct($input) {$this->var = $input;}}$myclass = new something(input_here_for_my_var);?>[/code]Now imagine that i want to have my var set to "hello". How can I make the call? Doing $myclass(var) does not work.Thanks for your help,P.B.C. Link to comment https://forums.phpfreaks.com/topic/22179-oop-question/ Share on other sites More sharing options...
trq Posted September 26, 2006 Share Posted September 26, 2006 [code=php:0]class something { var $var; function __construct($in) { $this->var = $in; }}[/code] Link to comment https://forums.phpfreaks.com/topic/22179-oop-question/#findComment-99312 Share on other sites More sharing options...
Barand Posted September 26, 2006 Share Posted September 26, 2006 One comment, you seem to mixing versions__construct is php5var is php4[code]<?php //v 5class something5 { public $var; function __construct($input) { $this->var = $input; }}$myclass = new something5('hello');echo $myclass->var;?>[/code][code]<?php //v 4class something4 { var $var; function something4($input) { $this->var = $input; }}$myclass = new something4('world');echo $myclass->var;?>[/code] Link to comment https://forums.phpfreaks.com/topic/22179-oop-question/#findComment-99315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.