RE: [PHP] Newbie Question
| From: | Cal Evans | Date: | Wed, 26 Feb 2003 04:34:34 +0000 |
| Subject: | RE: [PHP] Newbie Question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-137186@lists.php.net to get a copy of this message | ||
you have 2 functions named DBField. This was ok until 4.3. After 4.3 you
couldn't re-declare a function like this.
PHP does not allow for overloading like Java and C++ (It looks like that's
what you are trying to do)
Check the docs for overloading. There is some support for it but it's a bit
of a kludge. (IMHO, etc.)
=C=
* Cal Evans
* Stay Plugged Into Your Audience
* http://www.christianperformer.com
-----Original Message-----
From: Greg Luce [mailto:greg@thedatabaseplace.com]
Sent: Tuesday, February 25, 2003 9:47 PM
To: php-general@lists.php.net
Subject: [PHP] Newbie Question
Can someone explain why this code works on the hosting company's server,
but won't run on my local server? I'm not sure what version is on the
host server, but I'm running 4.0.5 locally on winXP Pro. The error says:
Fatal error: Cannot redeclare dbfield() in
c:\inetpub\wwwroot\livinginnaples\database.php on line 30
7.class DBField
8.{
9. var $name;
10. var $type;
11. var $table;
12. var $title;
13.
14. var $size;
15. var $rows;
16. var $maxlength;
17. var $value;
18. var $prefix;
19. var $postfix;
20. var $display;
21.
22. function DBField()
23. {
24. $name = "";
25. $table = "";
26.
27. $this->display = true;
28. }
29.
30. function DBField( $name, $table, $size, $value )
31. {
32. if( $size == "" ) $size=20;
33.
$this->display = true;
$this->name = $name;
$this->table = $table;
$this->size = $size;
$this->rows = 5;
$this->value = $value;
$this->title = ucwords( $name );
}
function display()
{
if( !$this->display ) return;
$prefix = str_replace( "[TITLE]", $this->title,
$this->prefix );
echo $prefix;
switch( $this->type )
{
case "blob": ?>
<textarea cols="<? echo $this->size ?>"
rows="<? echo $this->rows ?>" name="<? echo $this->name
?>"><? echo
$this->value ?></textarea><?
break;
case "date":
if( $this->value != "" ) $time =
strtotime( $this->value );
else $time = strtotime( "now" ); ?>
<input type="text" size="2"
maxlength="2" name="<? echo $this->name ?>m" value="<? echo
date( "m",
$time ) ?>">/<input type="text" size="2" maxlength="2"
name="<? echo
$this->name ?>d" value="<? echo date( "d", $time )
?>">/<input
type="text" size="4" maxlength="4" name="<? echo
$this->name ?>y"
value="<? echo date( "y", $time ) ?>">
<?
break;
default: ?><input type="text" size="<? echo
$this->size ?>" maxlength="<? echo $this->maxlength ?>"
name="<? echo
$this->name ?>" value="<? echo $this->value ?>"><?
break;
}
echo $this->postfix . "\r\n";
}
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php