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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:09:25+00:00 2026-05-20T20:09:25+00:00

According to you, what is the best solution in PHP to ensure the course

  • 0

According to you, what is the best solution in PHP to ensure the course of several php functions ?
For example function A must return True to initiate the B function, and the B function must return True to initiate another function…

Is there a system like Rollback / Commit in SQL to ensure that in PHP please ?

Thank you.

  • 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-20T20:09:26+00:00Added an answer on May 20, 2026 at 8:09 pm

    Doing a chain of functions would look something like this:

    try {
        if(!functionA()) {
            throw new Exception("Error message here", 100); // 100 can be any code, as long as it's unique to the other throw exception codes
        }
    
        if(!functionB()) {
            throw new Exception("Error message here", 101);
        }
    
        if(!functionC()) {
            throw new Exception("Error message here", 102);
        }
    } catch(Exception $e) { 
        /**
         * Do some actions depending on the error code of the exception (100, 101, 102)
         */
    }
    

    But if I understand correctly you want to perform a serie of operations and only if they are all successful you want them to be final, otherwise you want to undo all the operations?

    In this case it is hard to tell how you should implement this, cause you don’t tell what you want to achieve.

    But I can give you some advise. Most operations that are not reversable do have many possible checks. For example, if you want to be sure a file will be deleted from the filesystem you can first check if the file is writable (is_writable) and even exists (file_exists). If you first do all the checks of all operations and afterwards execute the operations, you can be pretty sure they will be executed successfully. Ofcourse it’s possible you forget checks, or some things can’t be checked, but I don’t see an other option to fix this.

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

Sidebar

Related Questions

I know 'best' is subjective, so according to you, what is the best solution
According to w3schools , the best HTML solution for embedding videos directly into a
According to Best way to remove from NSMutableArray while iterating? , we can't remove
According to Yahoo's Best Practices for Speeding Up your Site , the pros for
According to Marcin Ciura's Optimal (best known) sequence of increments for shell sort algorithm
According to MSDN form.RightToLeftLayout = True; form.RightToLeft = ifWeWantRTL() ? RightToLeft.True : RightToLeft.False; is
I'm having issues understanding how to configure TFS according to best practices as provided
The following code generates warning C4250. My question is, what's the best solution to
What is, according to you, the best way to convert uploaded files of any
I may have a problem imagining the best solution for a collision detection related

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.