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. Quote Link to comment 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] Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.