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

  • Home
  • SEARCH
  • 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 6626777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:56:03+00:00 2026-05-25T21:56:03+00:00

I want to make a single function for set_error_handler() to deal with undefined indexes

  • 0

I want to make a single function for set_error_handler() to deal with undefined indexes in an array with a specific name. For instance, the array is called: $products.
If I have

$products = array(1 => 'a', 2 => 'b' // etc...

and later execute call:

$a = $products[0];

I get an error. I want to handle the error only for the array with the name $products and no other.
How can I make that?

Please don’t give me alternatives to this method of solving the problem. I already had a discussion about that and it was decided that it really is better to use this method. I must also warn that this is a super simplification of the real thing.
I have already tried doing some research and nothing helped.

  • 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-25T21:56:04+00:00Added an answer on May 25, 2026 at 9:56 pm

    Setting up the error handler is easy enough – examples here – but filtering based on the code which actually triggered the error just isn’t achievable without some very messy regex matching (or something similar) against the error message string.

    You’re probably going to have to look at some other form of solution if you really require this functionality. You could use isset() to check index validity beforehand, or create an array-style class (e.g. using ArrayAccess or ArrayObject from the SPL) with some index-checking logic built-in.

    I know you didn’t want different solutions, but I’d be interested to find out why/how you decided that the method you’re proposing really is the best way?

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

Sidebar

Related Questions

I have style sheet with a class name changebackgroundcolor i want make change in
I want to keep everything contained within a single function, and not make all
i want to make a single wcf rest function which can return any content
I want to make many inserts in a single SQL statement, pretty much like
I want to make a really simple iphone app: one screen with a single
I want to make a simple game: 2d, single-player, without tons of animations and
I want to make a copy of an ActiveRecord object, changing a single field
I have got many dropdowns in my site and i want to make a
i want to make a single submission with dynamic jquery script but it doesn't
I have a function that takes either an array of IDs or a singular

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.