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 Link to comment https://forums.phpfreaks.com/topic/283740-set-public-variable-in-class-using-switch/ 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. Link to comment https://forums.phpfreaks.com/topic/283740-set-public-variable-in-class-using-switch/#findComment-1457624 Share on other sites More sharing options...
ignace Posted November 9, 2013 Share Posted November 9, 2013 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 Link to comment https://forums.phpfreaks.com/topic/283740-set-public-variable-in-class-using-switch/#findComment-1457630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.