Code: Select all
<?php
$connString = 'arbitrary connection string';
.
.
.
?>Thnx,
David
Moderator: General Moderators
Code: Select all
<?php
$connString = 'arbitrary connection string';
.
.
.
?>Code: Select all
<?php
define('MYCONST','some data');
?>Code: Select all
$my_global_variable="some global variable";
Code: Select all
include_once("vars.php");
class myclass{
function printmyglobal()
{
global $my_global_variable;
echo $my_global_variable;
}
}
My argument is that he will have to declare it as a global variable before he uses it, or use the globals array. With a constant he can just use it straight off the bat. I use constants in my configuration files.susrisha wrote:I would suggesting using global. I have been using it for many classes i wrote. I keep all the constants in a file and include it and get the variable wherever i needed.
To give an example;
vars.phpmyclass.phpCode: Select all
$my_global_variable="some global variable";Code: Select all
include_once("vars.php"); class myclass{ function printmyglobal() { global $my_global_variable; echo $my_global_variable; } }