Lingo Posted November 9, 2013 Share Posted November 9, 2013 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted November 9, 2013 Share Posted November 9, 2013 die($trainSloppyCheeseMen->turns);If you give an integer to die() then it will not be printed. die If you want to see the value, die($trainSloppyCheeseMen->turns . " turns");make it not an integer. Quote Link to comment Share on other sites More sharing options...
ignace Posted November 9, 2013 Share Posted November 9, 2013 (edited) 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 November 9, 2013 by ignace Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.