Be careful with require_once
Problem
You encounter this kind of error "Cannot redeclare class ..." even though you already used the require_once
to make sure that you include the file only once. What!?
Solution
The problem is, there's a chance that the path
that being included has different character cases from the physical file on the system. (Due to case sensitivity)
For example (The actual file is 'App/File.php'
)
<?php
require_once 'App/file.php';
# if you somehow run this require_once again. It will shows the error above
require_once 'App/file.php'
So, make sure you have the correct file name before execute the require_once
Written by Rezigned
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Related Tags
#php
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#