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
https://forums.phpfreaks.com/topic/136131-oop-calling-post_variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.