| re: Trouble accessing class member variable
"D. Alvarado" <laredotornado@gmail.com> wrote in message
news:ec027e73.0409190700.4abc6006@posting.google.c om...[color=blue]
> Hello, I am running PHP 4. I have this simple class,
>
> class CTable {
> var $m_name;
> var $m_primary_key_col_name;
> }
>
> then I have a function that takes, as argument, an instance of this
> class
>
> function bar($p_table) {
> $table_name = $p_table->m_name;
>
> but I get this parse error
>
> Parse error: parse error, unexpected T_VARIABLE in
> /usr/local/apache/htdocs/dev/util_fns.php on line 35
>
> I know this is some simple syntax thing. What am I doing wrong?
>
> Thanks, - Dave[/color]
Dave,
First the dumb question,
you have actually instantiated the class before passing it to the function ?
$fred = new CTable();
.. . . . .
bar($fred);
Second , what is in line 34 of /usr/local/apache/htdocs/dev/util_fns.php ?
missing semicolons in the row above can cause havoc.
HTH
Ron |