Connecting Tech Pros Worldwide Help | Site Map

Trouble accessing class member variable

  #1  
Old July 17th, 2005, 09:40 AM
D. Alvarado
Guest
 
Posts: n/a
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
  #2  
Old July 17th, 2005, 09:40 AM
Michael Fesser
Guest
 
Posts: n/a

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
  #3  
Old July 17th, 2005, 09:41 AM
Ron
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with calling one class from another d.s. answers 20 July 21st, 2008 10:55 PM
Multi-level inheritance and accessing base protected member variables Joseph Paterson answers 4 June 28th, 2007 03:05 PM
Access member variable directly or through property within the class it is defined? Joergen Bech answers 37 February 23rd, 2006 01:35 PM
Dispose / Destructor Guidance (long) Ken Durden answers 11 November 15th, 2005 08:46 AM