Error within class definition

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MMHein
Forum Newbie
Posts: 2
Joined: Sun Oct 29, 2006 1:20 am
Location: Vienna

Error within class definition

Post by MMHein »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

Just the other day I've downloaded "form_generator" from SourceForge, but unfortunately I can't get it up & running.

When running "php -al config/config.class.php" I always receive an error which I don't know how to solve:

Code: Select all

MH-Dual-G5:~/Sites/develop/form_generator heinm$ php -v
   PHP 4.4.1 (cli) (built: Mar  5 2006 10:30:50)
   Copyright (c) 1997-2004 The PHP Group
   Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
   MH-Dual-G5:~/Sites/develop/form_generator heinm$ php -al ./config/config.class.php
   Interactive mode enabled

   PHP Parse error:  parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in ./config/config.class.php on line 6
   Errors parsing ./config/config.class.php
   MH-Dual-G5:~/Sites/develop/form_generator heinm$
"config.class.php" looks like this:

Code: Select all

<?php
require_once('CDB.class.php');

class config
{
	public $db;
	public $tables;
	public $s;

	function __construct()
	{
		require_once('config.inc.php');
		$this->db = CDB::connectDB($dbHost, $dbName, $dbUser, $dbPass, $dbType);
		$this->tables = $tables;
		$this->configVars = $configVars;

		require_once($this->configVars['siteBasePath'].'/config/smarty/libs/Smarty.class.php');
		$this->s = new Smarty();
		$this->s->template_dir = $this->configVars['siteBasePath']."/templates/";
		$this->s->compile_dir = $this->configVars['siteBasePath']."/templates_c/";
	}
}

function __autoload($className)
{
	require_once("classes/".$className.".class.php");
}
?>
When testing all the required, included files seperately no error is found.

Any ideas?

Martin


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: Error within class definition

Post by timvw »

MMHein wrote: PHP 4.4.1 (cli) (built: Mar 5 2006 10:30:50)

PHP Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in ./config/config.class.php on line 6

public $db;
The script is writting for PHP5 because PHP4 doesn't support the access modifiers and wants class fields to be defined as following:

Code: Select all

class MyClass {
 var $db;
}
MMHein
Forum Newbie
Posts: 2
Joined: Sun Oct 29, 2006 1:20 am
Location: Vienna

Post by MMHein »

Okay, thanks a lot.

On the command line php4 is found before php5, my Apache is configured using php5.
Post Reply