Justin
Thank you now I have a working example to go from.
Justin Patrin wrote:
On Wed, 11 Aug 2004 16:35:33 -0500, Blake Schroeder <[EMAIL PROTECTED]> wrote:
I am trying to change some of my functions in to classes and objects. I
have been checking out the php.net and google and still not grasping the
concept.
here is my example all I am trying to do is print 2 numbers to the
browser that are randomly generated from dieRolls.
Thanks in advance
-Blake
class dieRolls{
function dieRolls($die){
$num = rand(1, $die);
You're storing this value in a local var, not an object property. Try:
$this->num = rand(1, $die);
$this->num;
This does nothing as $this->num is not set (see above) and you're not
*doing* anything with it.
}
}
$num1 = new dieRolls("6");
$num2 = new dieRolls("8");
$bar1 = $num1->bar1;
$bar2 = $num2->bar2;
I don't know what you think these two lines are doing. You never set
bar1 or bar2, so you'r enot going to get anything.
echo"Hi<br>\n";
echo"$bar1<br>\n";
echo"$bar2<br>\n";
I would suggest using this (after fixing the first problem I pointed out):
echo $num1->num."<br/>\n";
echo $num2->num."<br/>\n";
--
+-----------------+-----------------+----------------+
| Blake Schroeder | Owner/Developer | lhwd.net |
+--(http://www.lhwd.net)------------+--/3174026352\--+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php