Jump to content

oop calling post_variable


gish

Recommended Posts

Hi everyone,

 

I need some direction to make sure my oop is correct. Inside the class i have the following functions. But the function random_class has to make a  choice from a session variable. What I want to know is it alright to call the session variable directly or do I do it through the object call in the script if so how do I do it correctly?

class random
       {
private $correction_outcome;
private $random_post;	
private $answer_string;	
private $Name;	

function __construct($random_post) {	
			$this->random_outcome = $random_post;
}
public function random_class ($random_post){
//this is a will setup a cass choice so that it can choose a function
$Name = $_SESSION['form_value'];               //this needs to be a session
    switch($Name) {
        case "Jim": random_au(); break;
        case "Linda": random_su(); break;
        case "Bob": random_mu(); break;
        default: print "I'm broken and I don't know why\n";
    }								
}
   public function random_checked() {
            return $this->random_outcome;
            
   }
}

 

the object call is this,

 

		   $random_post = $_POST['form_value'];
			$random_object = new random($random_post);
			$random_object ->random_class($random_post);
			echo $random_object->random_checked();

 

If you see anything else that is wrong do tell me oo is still very new =)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.