Php Constants Tutorial

Constants are similar to variables (as they are used to store some data) but they have a fixed value: you cannot modify a constant after you have defined it.

In PHP constants can be defined by using the keyword define. It's considered good practice to use uppercase names for constants.


<?php #constants.php
//defining a constant

define("USERNAME", "John");

//using the constant
echo "<p>Hello, <strong>" . USERNAME . "</strong>.</p>";

Hello, John.


Click here to read about if-else statements

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Copyright © 2015 by Cramerz.com.