Skip to content

Commit

Permalink
Added PHP Constant
Browse files Browse the repository at this point in the history
  • Loading branch information
khianvictorycalderon committed Dec 25, 2024
1 parent 2a1f5d1 commit 2a0befb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Constant.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

// 2 ways to declare constant in PHP
// using define()
// using const
// With constant, $ (dollar sign) is not required

/*
using define()
syntax:
define(string $constant_name, mixed $value)
*/

// Case sensitive
define("CONSTANT_VAR", "This is a fixed value and cannot be changed<br/>");
echo CONSTANT_VAR;

// Using const
const ANOTHER_CONST_VAR = "This is another constant variable<br/>";
echo ANOTHER_CONST_VAR;

?>

0 comments on commit 2a0befb

Please sign in to comment.