|
Posted by Greg Scharlemann on 12/17/90 11:52
David Haynes wrote:
> Also, var is deprecated in PHP5.
Thanks!
Your test case also worked... but I'm going to make my question a
little more complicated...
That boolean value is going to be written to a MySQL database. I've set
the column to be of type Bool (which appears to turn into a
Tinyint(1)), is that the best approach? Should I use enum('true',
'false') or some other approach?
Second, since the values get screwed up when cast to a String, should I
just go around the true/false nominclature and use 1/0?
Finally, another somewhat semi-related newbie question. I come from a
java background with getter and setter methods. I modified the Test
class David created with what I thought is a getter method, however it
doesn't work... The function just prints: "()" PHP is not as straight
forward as I hoped...
<?php
class Test {
private $testBool;
public function __construct($testBool) {
printf("Test constructed with testBool = %s\n",
$testBool ? 'true' :
'false');
}
public function getTestBool() {
return "$testBool";
}
}
$testing = new Test(true);
$testing = new Test(false);
print "testing->getTestBool() = $testing->getTestBool()";
?>
Navigation:
[Reply to this message]
|