Ahh damn - minor omission - add a '( )' after myclass constructor name :-)
AndrewH
- Original Message -
From: "Andrew Halliday" <[EMAIL PROTECTED]>
To: "John LYC" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, March 05, 20
No, you cant do this as you coded it, however minor alterations will allow
this.
Last time i checked, you couldnt initialise variables in object scope ...
you can only declare them. This makes sense, because thats what the
constructor is for.
Altered code for what you want to do is as follows:
class myclass{
$fields = mysql_list_fields("database1", "table1", $link);
$columns = mysql_num_fields($fields);
for ($i = 0; $i < $columns; $i++) {
var mysql_field_name($fields, $i);
}
}//class
now.. can i do this?
is there a performnance issue here?
can i put this in the constructor?
joh
yes you can do all of this
but in no OO language so far have i seen the ability to access a variable
inside a method...you would have to do this:
class myclass
{
var $myvar;
function setmyvar($newmyvar)
{
$this->myvar = $newmyvar;
}
}
Then you could do this:
$myclassObj = new myclass(
4 matches
Mail list logo