IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesDelphi Prism  Print This     

Constants (Delphi Prism and PHP Cross Reference Guide)

By Mike Prestwood

Delphi Prism versus PHP: A side by side comparison between Delphi Prism and PHP.

 
Language Basics
 

Language basics is kind of a catch all for absolute beginner stuff. The items (common names) I chose for language basics is a bit random and include items like case sensitivity, commenting, declaring variables, etc.

Constants

[Other Languages] 

General Info: Computer Language Constants

A constant is just like a variable (it holds a value) but, unlike a variable, you cannot change the value of a constant.

Delphi Prism:   const kPI: Double=3.1459;

In Prism, you define constants similar to how you define variables but use the Const keyword instead of the Var keyword. Specifying the type is optional. If you don't specify the type, the compiler chooses the most appropriate type for you.

Declare class constants as part of the class definitions. Declare local constants above the begin..end. Although Prism support inline variables, inline constants are not supported.

Syntax Example:
//Specified type:
const
kFeetToMeter: Double = 3.2808;
  kMeterToFeet: Double = .3048; 
  kName: String = "Mike";

//Unspecified type:
const kPIShort = 3.14;
PHP:   define

In PHP, you declare constants using the define keyword:

define("CONST_NAME", "Value");

Constants in PHP are case sensitive. A common standard in PHP is to use all-uppercase letters, with underscores to separate words within the name.

Syntax Example:
define('FULL_NAME', 'Mike Prestwood');
define("AGE", 25);
  
echo "Your name is " . FULL_NAME . ".";
echo "You are " . AGE . ".";












Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]