Jump to content

PHP Define


Vivid Lust

Recommended Posts

It's not confusing when you take the time to read lol

 

Defines a named constant at runtime

Returns TRUE on success or FALSE on failure.

 

<?php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and issues a notice.

define("GREETING", "Hello you.", true);
echo GREETING; // outputs "Hello you."
echo Greeting; // outputs "Hello you."

?> 

Link to comment
https://forums.phpfreaks.com/topic/92468-php-define/#findComment-473731
Share on other sites

Yes, let me interject here as well.

 

A constant is something you want to define that WILL NEVER CHANGE through your entire script/app

 

A good example might be:

Take FORUMS for instance... in your preferences you set Date and Time.

 

In the code, a constant...

define("USERTIME", "-8"); // GMT-8 for Pacific time

... may be defined for use later.

 

This will never change in your script once defined and the use of constants is definitely a methodical thing.

Link to comment
https://forums.phpfreaks.com/topic/92468-php-define/#findComment-473758
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.