Code: Select all
define(X_MAX, 4); // data type integer
$x = 4.0; // data type double
if ($x == X_MAX) {
print("true<BR>");
}
else
print("false<BR>");Thanks in advance.
J
Moderator: General Moderators
Code: Select all
define(X_MAX, 4); // data type integer
$x = 4.0; // data type double
if ($x == X_MAX) {
print("true<BR>");
}
else
print("false<BR>");Code: Select all
// you should wrap the defined name with single or double quotes
define('FOO', 4);
$x = 4.0; // data type double
// I added an extra type check here...
if (is_int($x)) {
// same as yours, but shorter. just as example...
echo ($x == FOO ? 'true<br>' : 'false<br>');
} else {
echo 'Not an integer...<br>';
}Code: Select all
$x = 4.0;
echo $x; // returns 4
// but this verifies it...
if (is_float($x)) { echo 'yes'; }
else { echo 'no'; }Code: Select all
if ($this->startSide == "vertical") {
$this->width = Y_MAX - $this->startCoordinate->getY();
$this->height = $this->width * (tan(deg2rad($this->angleStart)));
$counter = 0;
$wrkMaxX = X_MAX;
$wrkMaxY = Y_MAX;
$xType = gettype($this->startCoordinate->getX());
$yType = gettype($this->startCoordinate->getY());
settype($wrkMaxX, $xType);
settype($wrkMaxY, $yType);
print("Data type for \$this->startCoordinate->getX() = "
.gettype($this->startCoordinate->getX())
."<BR>Data type for \$wrkMaxX = "
.gettype($wrkMaxX)." "."<BR>");
print("Value of \$wrkMaxX = ".$wrkMaxX
."<BR>Value of \$this->startCoordinate-getX() = "
.$this->startCoordinate->getX()."<BR>");
if ($this->startCoordinate->getX() <= $wrkMaxX)
print "true<BR>";
else
print ($this->startCoordinate->getX()
." is NOT less than or equal to ".$wrkMaxX." ?!?!<BR>");
while ($this->startCoordinate->getX() <= $wrkMaxX &&
$this->startCoordinate->getX() >= 0 &&
$this->startCoordinate->getY() <= $wrkMaxY &&
$this->startCoordinate->getY() >= 0) {
$this->vector[$counter] = $this->startCoordinate;
$width = $this->width - DECREMENT_VALUE;
$height = $width * tan(deg2rad($this->angleStart));
$xDiff = $this->height - $height;
$yDiff = $this->width - $width;
if ($this->priorStart->getX() <= $this->startCoordinate->getX()){
$newX = $this->startCoordinate->getX() - $xDiff;
}
else
$newX = $this->startCoordinate->getX() + $xDiff;
if ($this->priorStart->getY() <= $this->startCoordinate->getY()) {
$newY = $this->startCoordinate->getY() + $yDiff;
}
else
$newY = $this->startCoordinate->getY() - $yDiff;
$this->startCoordinate->setX($newX);
$this->startCoordinate->setY($newY);
$counter++;
}
}Code: Select all
Data type for $this->startCoordinate->getX() = double
Data type for $wrkMaxX = double
Value of $wrkMaxX = 4
Value of $this->startCoordinate-getX() = 4
4 is NOT less than or equal to 4 ?!?!