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 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

well right now I basically have the jquery load function like this $('#results').load(sources.php?source=1&page=<?=$_GET['page']?>&search=<?=$_GET['search']?>); so
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 a function like this public static string GetNumberOfColumns(string ConnectionString) { StringBuilder sb
I have a function like this to prompt the user to confirm they want
I have written a template function like this: template <class T> const T& max1(const
I have a file like this: 1234 1234 First Name Last Name And I
I have a function like this #define LEN 10 #define MAX 200 void f(char
I have a Function like this; ALTER FUNCTION [dbo].[fngcodeme] ( @HESAP INT, @DOV INT,
Say you have a function like this : SmartPtr<A> doSomething(SmartPtr<A> a); And classes like

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.