Setting Environment Variables

Setting environment variables in your server configuration
on a host-by-host basis allows you to configure virtual hosts differently.

<?php
putenv('ORACLE_SID=ORACLE'); // configure oci extension
?>
 

Adjusting behavior based on an environment variable

 <?php
$version = $_SERVER['SITE_VERSION'];

// redirect to http://guest.example.com, 
//if user fails to sign in correctly
if ('members' == $version) {
    if (!authenticate_user($_POST['username'], $_POST['password'])) {
        header('Location: http://guest.example.com/');
        exit;
    }
}
include_once "${version}_header"; // load custom header

http://www.php.net/putenv; information on setting environment 
variables in Apache at 
Related Posts:
  • php file_get_contents This function is the preferred way to read the contents of a file into a string. The function itself does nothing but puts the source of the web page you supply it into a string available for us… Read More
  • Use $_POST to get input values It will execute the whole file as PHP. The first time you open it,  $_POST['submit']  won't be set because the form has not been sent.    <?php if (isset($_POST['submit'])) { $example = $_POST['… Read More
  • What is difference between mysql_fetch_array(),mysql_fetch_row() and mysql_fetch_object() ? mysql_fetch_array():: fetches a result row as a associated array, numeric arraymysql_fetch_object: Fetaches a result row as object.mysql_fetch_row::fetches a result row as array … Read More
  • Storing Complex Data Types You can use sessions to store complex data types such as objects and arrays simply by treating them as standard variables, as this code shows: $myarr["0"] = "Sunday"; $myarr["1"] = "Monday"; $myarr["2"] = "Tue… Read More
  • P ARSING XML Two techniques are used for parsing XML documents in PHP:SAX(Simple API for XML) andDOM(Document Object Model). By using SAX, the parsergoes through your document and fires events for every start and stop tag orother element… Read More
  • Sorting One Array at a Time PHP functions for sorting an array Effect Ascending Descending User-defined order Sort array by values, then reassign indices starting with 0 sort( ) rsort( ) usort( ) Sort array by values … Read More
  • php exec The exec() function is one of several functions you can use to pass commands tothe shell. The exec() function requires a string representing the path to the commandyou want to run, and optionally accepts an array variable th… Read More
  • Encoding php file str_rot13() base64_decode()   Try ionCube PHP Encoder,  link - http://www.ioncube.com/sa_encoder.php        There are only two worthwhile players in the encoding market, Zend Guard ($600) and i… Read More
  • mod_rewrite? Rewrites the requested URL on-the-fly based on configuration directives and rules. You are using system paths. Apache mod_rewrite only works with URLs,   RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} … Read More
  • PEAR class: System The System PEAR class is available as part of the basic PEAR install:<?phprequire_once "System.php";$tmp_file = System::mktemp();copy("http://php.net/robots.txt", $tmp_file);$pear_command = System::which("pear");?>PEAR… Read More
  • How can we find the number of rows in a MySQL table? By Mysql SELECT COUNT(*) FROM table_name; … Read More
  • Check if image file ?? allow_url_fopen is activated in your PHP config     $filename = "http://".$_SERVER['SERVER_NAME']." /media/img/".$row['CatNaam'].".jpg"; echo" <img src=\"".$filename."\" alt=\"".$row['CatNaam']."\">"; … Read More
  • PHP Write and Read from File $fp = @fopen ("text1.txt", "r"); $fh = @fopen("text2.txt", 'a+'); if ($fp) { //for each line in file while(!feof($fp)) { //push lines into array $thisline = fgets($fp); $thisline1 = trim($thisline); … Read More
  • Cannot modify header information Check that <?php is at the very start of the functions.php file (before any whitespace) and remove ?> at the end of that file. header or setcookie or anything else that sends HTTP headers has  to be done before&n… Read More
  • SELECTING DATA IN PHP You frequently select data in a MySQL table using PHP. Selecting data through a PHP programusing a MySQL command takes four steps:1. Make a connection to the database.2. Create a safe query with the command.3. Run the query.… Read More