Expecting T_FUNCTION ?
Posted: Wed Aug 12, 2009 8:05 am
Hi,
i have this wierd problem, this is my code:
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?
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;
}
}
?>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?