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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:23:02+00:00 2026-05-28T19:23:02+00:00

What is the syntax to find out in method2 whether method1 one returned true

  • 0

What is the syntax to find out in method2 whether method1 one returned true or false?

class myClass{
public function method1($arg1, $arg2, $arg3){
   if(($arg1 + $arg2 + $arg3) == 15){
      return true;
   }else{
     return false;
   }
}

public function method2(){
   // how to find out if method1 returned true or false?
}
}

$object = new myClass();
$object->method1(5, 5, 5);
  • 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-28T19:23:03+00:00Added an answer on May 28, 2026 at 7:23 pm

    To do as you propose you could do it a few ways:

    1) Call the method 1 inside method 2

    public function method2(){
       // how to find out if method1 returned true or false?
       if(method1($a, $b, $c))
       {
           //do something if true
       }
       else
       {
           //do something if false
       }
    }
    

    2) Call it before method 2 (a bit weird to do it this way but possible and could be needed depending on context)

    $method1_result = method1($a, $b, $c);
    
    method2($method_result);
    
    //inside method 2 - change the constructor to take the method 1 result. e.g. method2($_method1_result)
    
    if($_method1_result)
    {
        //do something if true
    }
    {
        //do something if false
    }
    

    If you are only going to need the result of method 1 ONCE (thus the return value of method 1 doesn’t change) then and are going to call method 2 many times then you can be more efficient to do it outside of method 2 to save re running the same code (method 1) every time method 2 is called.

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

Sidebar

Related Questions

I'm just starting out with F# and I can't find the syntax to do
I find this syntax astoundingly annoying. Every time I rename my class, I have
I'm trying to find out all available syntax/format in Gherkin, such as about multiline
What I am trying to find out is the proper syntax to apply some
I have tried to find out what's wrong. The table is conditions_loop. One column
I can't seem to find the syntax for editing an already-created stored procedure in
I came across this line in some code and can't find the syntax defined
For months now I've been trying to find a code syntax formatting extension that
Does anyone know if I can find an emacs color syntax configuration which resembles
I know how to find what I need from XML using XPath. The syntax

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.