cornelombaard Posted December 17, 2008 Share Posted December 17, 2008 I get the following error Cannot redeclare count() in /var/www/html/testphp/1.php on line 14 with the code looking like this: <html> <head> <title>This whole file will be used to learn PHP and within two months.</title> </head> <body> <?php function count() { static $count = 0; $count++; return $count; } print count(); print count(); ?> </body> </html> What am I doing wrong or is the book wrong? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted December 17, 2008 Share Posted December 17, 2008 count() is a PHP function...you cannot over-ride it with your own function. use something unique: <html> <head> <title>This whole file will be used to learn PHP and within two months.</title> </head> <body> <?php function my_count() { static $count = 0; $count++; return $count; } print my_count(); print my_count(); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.