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 5953323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:48:32+00:00 2026-05-22T17:48:32+00:00

I have now a function like this function checkInput($content, $emptyMessage = ){ if(isset($content)){ return

  • 0

I have now a function like this

function checkInput($content, $emptyMessage = ""){
    if(isset($content)){ 
       return sanitize($content);
    }else{
       return $emptyMessage;
    }
 }

And I use it like this:

/* First get all data out of key and put it in array*/

//now check the input if user has set certain fields
$email = checkInput($user["email"],"No email address given");

echo $email;

Now I get: Uncaught ErrorOrWarningException.
I can think of two solutions:

Turning off errors > dont like that one.

Do manually for every field like

if(isset($user["email"])){ 
     $email = sanitize($user["email"]);
}else{
     $email =  "No email address given";
}
echo $email;

That sucks for readibility.
Another way would be to try / catch but thats almost the same length to type

  • 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-22T17:48:33+00:00Added an answer on May 22, 2026 at 5:48 pm

    When declaring a function with parameters, the parameter will always be set inside the function.

    function checkInput($content, $emptyMessage = "") {
        // $content is always "set" here, no need for isset()
    

    You’re getting a warning if you’re trying to access a non-existent variable here:

    checkInput($user["email"], "No email address given");
      //       ^^^^^^^^^^^^^^
      // if 'email' is not set, a warning is thrown here
    

    You’ll always need to make sure the "email" key is set before trying to pass its value into a function.

    Having said that, that’s probably not the cause of your ErrorOrWarningException. I have no idea where that comes from, it’s not standard PHP. I suppose your sanitize function is throwing it. If so, you’ll need to try and catch inside your checkInput function.

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

Sidebar

Related Questions

I have function like this in my header function bingframe() { var iframe =
i have function which is something like this function multiple_delete($entity1,$entity2,$entity2) { $query = SELECT
I have now worked on two different teams that use the Agile/Scrum approach in
What I have now (which successfully loads the plug-in) is this: Assembly myDLL =
I asked before about pixel-pushing, and have now managed to get far enough to
I use Delphi for many years, and although I have now moved on to
I have now 1gb ram at work(i hope that will change soon) and jboss
I have now seen 2 methods for determining if an argument has been passed
We are trying to implement a REST API for an application we have now.
We're currently running with php 5.2.5. We have now encountered a bug that creates

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.