www.  
Frequently Asked Questions
Tutorials
AIHOST Forums
Contact AIHOST Support

 

PHP Tutorial

How do I create a constant using PHP?
A constant is a name that represents a value you want to remain the same throughout a PHP script. Regardless of where a constant is created in a PHP script, the constant can be accessed anywhere in the script.

The define function is used to create a constant in your script. The name of the constant you want to create must be specified first. Constant names must start with a letter or an underscore (_) character. To help distinguish constants from variable, you should use all uppercase letters in a constant name. The name of the constant must be enclosed in quotation marks (" ") when specified in the define function. An example is below:

<html>
<head>
<title>User-defined Constants</title>
</head>
<body>
<? //creates a constant
define("AUTHOR", "Author Name");
print "This page was created by ";
print AUTHOR; //The output will be: This page was created by Author Name
?>
</body>
</html>
 
Escape Sequence Description
__FILE__ Returns the filename of the script being processed.
__LINE__ Returns the number of the line being processed in the script.
PHP_VERSION Returns the version number of PHP being used.
PHP_OS Returns the name of the operation system running PHP.
TRUE Stores a value of true
FALSE Stores a value of false. related to parsing.
E_ERROR Indicates a fatal error that is not related to parsing.
E_WARNING Indicates that an error has occurred, but PHP will continue processing the script.
E_PARSE Indicates a fatal parsing error caused by invalid syntax in the script.
E_NOTICE Indicates that an error may have occurred, but PHP will continue processing the script.
E_ALL Represents all the E_* constants. If used with the error_reporting function, all problems noticed by PHP will be reported.
NULL Represents no value.

 

 
Online Forums  ::   Services ::   About Us  ::   Support  ::    Contact Us  ::    Login  ::    Home  
AIHOST.NET™ 2006. All rights Reserved, Powered By TelNex Technologies, Inc.