fluidsharp Posted March 5, 2010 Share Posted March 5, 2010 Hello dear Please give me advise. I'm learning class and didn't understand how to get access to more then 1 properties of class. I'm using getter and setter method. abstract class father { protected $title; protected $result; } class connectDB extends father { protected $select; protected $i; function setQuery($query) { //something code //$resultFetch - is array, $i - quantity of iteration $this->select = $resultFetch; $this->i = $i; } function getQuery($select,$i) { return $this->select; return $this->i; } } $db = new connectDB(); $sel = "SELECT * FROM......etc"; $db->setQuery($sel); $get = $db->getQuery($selResult, $quantIter); // <- how to get both "$select" and "$i" I get value only from properties - "protected $select" to $get, but ($selResult, $quantIter) are = NULL How to get both values together ??? Link to comment https://forums.phpfreaks.com/topic/194236-getting-two-properties-from-class/ Share on other sites More sharing options...
cags Posted March 5, 2010 Share Posted March 5, 2010 You certainly can't go about it like that. Once you call return, a function (in this case method) is finished. The second return statement will never get ran. I can't really give any advice towards a solution, because I really don't understand what you are trying to do. If you need more than one item to come back from a getter in that manner, you will either have to pass the variables in as reference types rather than value types, or you will have to add all items you wish to return to an array and return the array. Link to comment https://forums.phpfreaks.com/topic/194236-getting-two-properties-from-class/#findComment-1022005 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.