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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:58:39+00:00 2026-06-18T17:58:39+00:00

My apologies if I misstate something or use an incorrect term. But I was

  • 0

My apologies if I misstate something or use an incorrect term. But I was trying to figure out how to use an if statement on an object.

This works just fine and as I understand it, the @ suppresses errors.

if (@mail("$receiver_email", "$subject", "$message", "$headers")) { }

However If I do this it fails:

if (@$mail->send('email@gmail.com', "$receiver_email", "$subject", "$message")) {}

The irony is that the email goes through but the IF fails. How can I fix the IF statement so it works properly?

  • 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-06-18T17:58:41+00:00Added an answer on June 18, 2026 at 5:58 pm

    First of all, don’t use @. It’s bad practice and better dealt with using error handling routines; see also: Error logging, in a smooth way

    From your code I can only guess that your code is like this:

    public function send($from, $to, $subject, $message)
    {
        // your code here
    }
    

    If the function doesn’t have a return value, it defaults to null and that evaluates to false which is why the IF “fails”.

    You should return a success value from your send() method.

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

Sidebar

Related Questions

Apologies if this question is a duplicate, or if I've missed something, but in
Apologies if I'm missing something really obvious, but I'm trying to understand how to
Apologies if this has already been covered but what are the advantages/disadvantages of using
Apologies in advance for the rudimentary nature of this CSS question. I'm trying to
Apologies but I haven't found what I needed from other threads OR I just
Apologies if this has been answered elsewhere; I've tried searching, but haven't found anything
Apologies for the basic question but I am trying to add a hover state
Apologies I know this is a well covered question, but I cant seem to
Apologies for the total beginner's question but I'm tearing my hair out here ...
Apologies if this is really simple but I'm fairly new to programming. I've created

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.