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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:25:15+00:00 2026-05-16T16:25:15+00:00

if (isset ($_POST[‘somethingA’])) { //code for doing something A } elseif (isset ($_POST[‘somethingB’])) {

  • 0
 if (isset ($_POST['somethingA']))
 {
      //code for doing something A
 }
 elseif (isset ($_POST['somethingB']))
 {
      //code for doing something B
 }

I will need to access some data from somethingA code, into somethingB code.

How can I do that in a proper way?

Should I declare a variable outside the conditionals, work inside the conditionals, and later (bottom) I use that?

Should I work with them inside the conditionals, and, somehow, pull them out after the conditional lines?

Thanks in advance,
MEM

  • 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-16T16:25:16+00:00Added an answer on May 16, 2026 at 4:25 pm

    you may do something like you said:

    $innervar = null;
    
    if (isset ($_POST['somethingA']))
     {
          $innervar = new A();
          //code for doing something A
     }
     elseif (isset ($_POST['somethingB']))
     {
          $innervar = new B();
          //code for doing something B
         }
    
    $innervar->CommonMethod();
    

    If you are accesing $_POST directly consider using some sort of framework like symfony, or Zend, unless you are learning or working in a very simple(house) project.

    Best of luck
    David

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

Sidebar

Ask A Question

Stats

  • Questions 529k
  • Answers 529k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've now added some Try Catch statements in and it… May 16, 2026 at 11:21 pm
  • Editorial Team
    Editorial Team added an answer I got it! Here: map.resources :regions, :collection => {:select_for_payroll =>… May 16, 2026 at 11:21 pm
  • Editorial Team
    Editorial Team added an answer I'd still like to know the problem, but I've worked… May 16, 2026 at 11:21 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Here is my code: if (isset($_POST['addmonths'])){ if (!empty($_POST['months'])){ if (is_numeric($_POST['months'])){ $monthtoadd = $_POST['months']; if
Here is my code: if (isset($_POST['addmonths'])){ if (!empty($_POST['months'])){ if (is_numeric($_POST['months'])){ $monthstoadd = $_POST['months']; if
Here is my code: if(isset($_POST['check']) AND $_POST['check'] == 'First') { $errormessage = array(); if(empty($_POST['full_name'])
I have the following code presently: if(isset($_POST['Movie'])) { $check = $_POST['Movie']; echo (left angle
Having a little bit of trouble with this section of code: if(!empty($_POST['RemoveRequest']) && isset($_POST['RemoveRequest'])){
I tried using: // do login if request is posted if (isset($_POST) && !empty($_POST))
if (isset($_POST['login'])) { $query = mysql_query(" SELECT id FROM users WHERE username = '".mysql_real_escape_string($_POST['username'])."'
if( isset( $_POST['aquafina'] ) && $_POST['aquafina'] != '' ) { $message .= AquafinA: .(
$items = (isset($_POST['items'])) ? $_POST['items'] : array(); I don't understand the last snippet of
Is there any speed difference between if (isset($_POST['var'])) or if ($_POST['var']) And which is

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.