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

Constants (Perl and PHP Cross Reference Guide)

By Mike Prestwood

Perl versus PHP: A side by side comparison between Perl 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.

Perl:   use constant

In Perl, you declare constants using the use constant keywords:

use constant CONST_NAME => "Value";

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

Syntax Example:
use constant FULL_NAME => 'Mike Prestwood';
use constant AGE => 38;
  
print "Your name is " . FULL_NAME . ".<br>";
print "You are " . AGE . ".<br>";
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 . ".";












Sales Website: www.prestwood.com Or visit our legacy sales site: 
legacy.prestwood.com


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