Page 1 of 1

Expecting T_FUNCTION ?

Posted: Wed Aug 12, 2009 8:05 am
by DoubleUB
Hi,

i have this wierd problem, this is my code:

Code: Select all

<?php 
 
abstract class UserPrefs 
{ 
   $tablename = ''; 
    
   abstract function form_details(&$data, $uid, $method); 
   abstract function handle_form(&$data, $uid, $method); 
    
   function get_table_data($uid) 
   { 
      DBase::query("SELECT * FROM {$this->tablename} WHERE user_id = {$uid}"); 
      if (($data = DBase::fetch_result()) === FALSE) $data = array(); 
      return $data; 
   } 
    
   function get_post_data() 
   { 
      $data = array(); 
      foreach ($_POST as $key => $val) 
         if (preg_match("/^({$this->tablename}_)(.*)/", $key, $matches)) $data[$matches[2]] = $val; 
      return $data; 
   } 
} 
 
?>
And when i try to run this, PHP gives me this error:
Parse error: parse error, expecting `T_FUNCTION' in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\cms\userprefs.php on line 5

So what? I can only declare functions inside an abstract class? Also, when i write a class extending this one, and I put '$tablename = 'anything';' in it, PHP also gives me this error. Anyone got any clue what I'm doing wrong here?

Re: Expecting T_FUNCTION ?

Posted: Wed Aug 12, 2009 8:13 am
by Mark Baker
public, private, protected?

Re: Expecting T_FUNCTION ?

Posted: Wed Aug 12, 2009 9:14 am
by DoubleUB
Ah, that works. Not really used to using visibility keywords in PHP.