Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

bugs. If you discover a constant mysteriously evaluating to zero, check that the constant
has been defined.


<?
/*
* Database variables
/
define("DATABASE_HOST", "localhost");
define("DATABASE_USER", "httpd");
define("DATABASE_PASSWORD", "");
define("DATABASE_NAME", "freetrade");


print("Connecting to ". DATABASE_HOST. "
\n");
?>


boolean defined(string constantname)


The defined function returns TRUE if a constant exists, FALSE otherwise.


<?
define("THERMOSTAT","72 degrees");
if(defined("THERMOSTAT"))
{
print("THERMOSTAT is ". THERMOSTAT);
}
?>


double doubleval(expression)


The doubleval function returns its argument as a double. Chapter 2 discusses
converting between data types. Related functions are strval and intval. It is an error to
pass an array or object to doubleval.


<?
$myNumber = "13.1cm";
print(doubleval($myNumber));
?>


empty


This function is an alias for isset.


string gettype(expression)

Free download pdf