php - unable to use variables defined in class -


hi trying import configuration variables config file had created

config.php has

class config {     public $servername = '*******';     public $susername = '*********';     public $spassword = '*********';     public $dbname2 = '********'; } 

for importing variable in file tried

include('./config.php') or die("error"); $cnfig = new config(); 

but when try use $cnfig->dbname2 not working

please sole problem.

thank you.

edit

it working in localsystem , when tied upload through web hosting not working.

try below one

include  ('./config.php'); $cnfig = new config(); echo "<pre>";print_r($cnfig); 

edit:

i getting below output should working too.

config object (     [servername] => *******     [susername] => *********     [spassword] => *********     [dbname2] => ******** ) 

edit:2

you can this

(include('./config.php')) or die("error"); $cnfig = new config(); echo "<pre>";print_r($cnfig); 

http://www.php.net/manual/en/function.include.php#39043

or has higher priority include()

error ouput:

when use include('./config.php') or die("error"); it's giving below error.


warning: include(1) [function.include]: failed open stream: no such file or directory in d:\path_to_file\myconfig.php on line 2

warning: include() [function.include]: failed opening '1' inclusion (include_path='.;d:\zendserver\share\zendframework\library') in d:\path_to_file\myconfig.php on line 2

fatal error: class 'config' not found in d:\path_to_file\myconfig.php on line 6


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -