Jump to content

set public variable in class using switch


Lingo

Recommended Posts

Ok so I have a class with a switch that changes a variable in the class depending on some conditions. 
 

Safe to say it doesnt work.

         
         $trainSloppyCheeseMen = new trainSloppyCheeseMen(); // Get train class
         $sloppyCheeseLock = new sloppyCheeseLock(); // Get sql inject scrubber class.
		 
		 

            $trainSloppyCheeseMen->type = 1; // Type is Orbital Platform
            

	

          //die("a");
            $sloppyCheeseLock->vulnerable = $_POST['miner'];
            $sloppyCheeseLock->sloppyUniverseProtect();
				
				
            $trainSloppyCheeseMen->amt = $sloppyCheeseLock->sloppyUniverseProtect();// Amount to Train


  switch ($trainSloppyCheeseMen->amt){
                
                case $trainSloppyCheeseMen->amt <= 10000:
                $trainSloppyCheeseMen->turns = 1; 
                break;
            
                case $trainSloppyCheeseMen->amt >= 10001 && $trainSloppyCheeseMen->amt <= 100000:
                $trainSloppyCheeseMen->turns = 2; 
                break;
            
                case $trainSloppyCheeseMen->amt >= 100001 && $trainSloppyCheeseMen->amt <= 5000000:
                $trainSloppyCheeseMen->turns = 5; 
                break;
            
                case $trainSloppyCheeseMen->amt >= 5000001 && $trainSloppyCheeseMen->amt <= 20000000:
                $trainSloppyCheeseMen->turns = 15; 
                break;
            
            
            
                default:
                $trainSloppyCheeseMen->turns = 1; // How many turns to train these buggers
                break;
                
            }

die($trainSloppyCheeseMen->turns);


They variable turns in the class is set to public but when I die it returns nothing.

 

Please help thanks,

Lingo

Link to comment
Share on other sites

Same as topic: http://forums.phpfreaks.com/topic/283709-my-first-class/?do=findComment&comment=1457483 with the same answer..

 

If you are going to use objects at least learn to use them properly:

 

$cheeseMen = new TrainSloppyCheeseMen($amount);
$cheeseMen->getTurns();
Where getTurns contains your switch code and operates on $this->amount Edited by ignace
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.