Connecting Tech Pros Worldwide Forums | Help | Site Map

Trouble accessing class member variable

D. Alvarado
Guest
 
Posts: n/a
#1: Jul 17 '05
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

Michael Fesser
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Trouble accessing class member variable


.oO(D. Alvarado)
[color=blue]
>Hello, I am running PHP 4. I have this simple class,
>[...]
>
>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[/color]

What is on line 35? Please post that line _and_ the lines before, if
possible all lines from the start. In many cases the cause for a parse
error is not found in the line where the interpreter recognizes it and
complains about it, but somewhere before.

Micha
Ron
Guest
 
Posts: n/a
#3: Jul 17 '05

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


Closed Thread