• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

My Monkey Do

A Log of Coding Solutions

  • Home
  • Web Hosts
  • Tools
  • About

Cannot redeclare class require_once

June 12, 2012 by Webhead

Problem

I’m using classes and making each class a file. when I’m including dependet classess, I use require_once to avoid multiple declarations – yet I get a Fatal error: Cannot redeclare class…

 

Solution

Make sure all files that require the class have require_once and also make sure that the path that is required is the same case in all situations.  For example, my problem was that I was including a “/Users/name/xxx.php” and “/users/name/xxx.php”.  These paths are different and so PHP includes both of these.

 

keywords: Cannot redeclare class require_once
source: http://bytes.com/topic/php/answers/461064-require_once-doesnt-work-cannot-redeclare-class

 

Filed Under: Coding Tagged With: debug, php

Primary Sidebar

Topics

apache apple block editor chrome cms css debug eCommerce embed firebug firefox git gmail goDaddy google hosting htaccess html html 5 IE crap image iPad iPhone javascript jquery linux localization mac os x ms sql mysql open source optimize php php 5.3 responsive rest api seo svg tinymce woocommerce wordpress wpengine xss yii youtube




Categories

  • Coding
  • Off the Shelf
  • Plugins
  • Random Thoughts
  • Server Stuff
  • Tools