Jump to content

define() and require_once()


flash gordon

Recommended Posts

Okay, so the docs say define() defines a constant value in php but it is also global as well? How does that define method work? I specifically asking for stuff like

define("AMFPHP_BASE", realpath(dirname(dirname(dirname(__FILE__)))) . "/");
require_once(AMFPHP_BASE . "shared/app/BasicGateway.php");
require_once(AMFPHP_BASE . "shared/util/MessageBody.php");

but now other class don't define() AMFPHP_BASE but are able to have access to the constant.

 

how it is typically used?

Link to comment
Share on other sites

define

supported in (PHP 4, PHP 5)

 

purpose

define — Defines a named constant

 

Description

bool define ( string $name , mixed $value [, bool case_insensitive = false ] )

 

Defines a named constant at runtime.

 

name

The name of the constant.

 

value

The value of the constant; only scalar and null values are allowed. Scalar values are integer, float, string or boolean values. It is possible to define resource constants, however it is not recommended and may cause unpredictable behavior.

 

case_insensitive

If set to TRUE, the constant will be defined case-insensitive. The default behavior is case-sensitive; i.e. CONSTANT and Constant represent different values.

 

Report a bug

Return Values

 

Returns TRUE on success or FALSE on failure.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.