note 40806 deleted from function.defined by nlopess
| From: | nlopess@php.net | Date: | Mon, 15 Mar 2004 15:45:42 +0000 |
| Subject: | note 40806 deleted from function.defined by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66869@lists.php.net to get a copy of this message | ||
Note Submitter: defined@NOSPAM.phpyellow.com
----
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.
*/
?>