note 40806 added to function.defined
| From: | defined at NOSPAM dot phpyellow dot com | Date: | Mon, 15 Mar 2004 15:43:14 +0000 |
| Subject: | note 40806 added to function.defined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66868@lists.php.net to get a copy of this message | ||
defined() is exceptionally useful when building an online application. With the defined() function
you can create application wide CONSTANTS and then with a simple require_once line you can bring
these CONSTANTS into your application. Example:
<?php
// Database connectivity - start
define("DBNAME", "enter_database_name" );
define("DBUSERNAME", "enter_dbuser_name" );
define("DBPASSWORD", "enter_dbpassword" );
define("DBSERVERHOST", "localhost" );
// Database connectivity - end
// URL, email and organization details - start
define("INSTALL_URL", "http://localhost/yourdomain.com/");
define("WEBMASTER", "info@NOSPAMyourdomain.com" );
define("SYSTEMEMAIL", "no-reply@NOSPAMyourdomain.com" );
define("ORGANIZATION", "Your Organization" );
define("ADMINHOME", "admin.php");
define("ADMINUSER", "admin");
define("ADMINPASSWORD", "admin");
define("LEGALNAME", "Your Legal Name");
define("PRODUCTNAME", "Your Application Name");
define("INSTALLVERSION", "1.1");
// URL, email and organization details - end
/*
save this file as secret.php and then bring these CONSTANTS into your application using the form:
*/
require_once("secret.php");
/*This makes changing the database name a snap - if used in the invoking pconnect():
// pconnect, select and query */
if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, DBPASSWORD)) {
if ( mysql_select_db(DBNAME, $link_identifier)) {
// your $query and processing here
)
/*
I also use it to declare database table names, so the user can easily customize their
implementation.
*/
?>
----
Manual Page -- http://www.php.net/manual/en/function.defined.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40806
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40806&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40806&report=yes
Search -- http://master.php.net/manage/user-notes.php