Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 554451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:42:39+00:00 2026-05-13T11:42:39+00:00

I run into this problem periodically, and I’m trying to figure out if it’s

  • 0

I run into this problem periodically, and I’m trying to figure out if it’s a configuration issue or a peculiarity with PHP.

Basically, there will be a function foo() defined somewhere in my code, and then elsewhere I will accidentally define a function again with the same name foo(). I would expect an error of some kind to be thrown, e.g. “Fatal Error: Function already defined line 234, bar.php blah blah”.

But I get nothing. I just get a blank screen. Debugging can take an eternity as I try to pinpoint exactly where the function is being accidentally redefined, without help from an error message.

My config settings for reporting errors are set to E_ALL, and I see all other kinds of errors without a hitch.

Any insights? Is there anything I can do to cause PHP to report these errors (so that I can either rename the offending function or wrap it in an if function_exists() clause)?

Edit: To be clear, I understand the many strategies to avoid namespace collisions in PHP. I’m talking about instances where for whatever reason I accidentally name a function a name that already exists during development (or for example I import a file where a function has already been defined). I would expect an error message when this occurs, which would help me debug, but I do not get one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:42:39+00:00Added an answer on May 13, 2026 at 11:42 am

    You can wrap function definitions in a conditional function_exists():

    if (!function_exists("file_get_contents"))
     {
       function file_get_contents(....)
         ....
     }
    

    works for me.

    You could wrap a function_exists check around each function and have it throw an error message if it already exists. The better way however would be finding out why fatal errors don’t appear on screen. Can you check phpinfo() for the error_reporting and related settings?

    This is what you should be getting when trying to redefine a function:

    Fatal error: Cannot redeclare file_get_contents() in D:\xyz\htdocs\test.php on line 5
    

    From my phpinfo():

    display_errors On

    error_reporting 22519 (equals… well, I don’t know but it shows errors 🙂

    In some hosting environments when error reporting was turned off completely, I have found defining a custom error handler very helpful: set_error_handler()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've run into this problem before and couldn't figure it out, but it's basically
I have run into this problem multiple times, and I cannot figure out why
I was trying to create Hibernate Validator bean, and run into this problem creating
I run into this problem again and again; Situation there is a (large) dataset
I'm hoping someone has run into this problem before and can help me out.
I have run into this problem in my Codeigniter app: A PHP Error was
Whilst trying to do pagination I've run into this problem. My table- ID CarBrand
Has anyone else run into this problem before? I've got a method that calls
Has anyone run into this problem... In my layout.phtml I have: <head> <?= $this->headTitle('Control
Has anyone run into this problem? I have a collection of comments that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.