coder330 Posted March 15, 2009 Share Posted March 15, 2009 he guys, everyone one on this forum has been really helpful, thanks for all the help! 1 more question: so I have a file called "config.inc.php" that has an array with all the database connection information. when "include_once" this file in a simple php file such as test.php, it works fine as i simply get array values. ex: $config['database'], $config['username'] etc. but when i "include_once" it in a php class such as test.class.php, it doesnt work. can you tell me what am i doing wrong? how do i include it in a class. Link to comment https://forums.phpfreaks.com/topic/149491-include-files-in-php-class/ Share on other sites More sharing options...
ram4nd Posted March 15, 2009 Share Posted March 15, 2009 Try to include it in top of your test.class.php file not in the class. Link to comment https://forums.phpfreaks.com/topic/149491-include-files-in-php-class/#findComment-785061 Share on other sites More sharing options...
coder330 Posted March 15, 2009 Author Share Posted March 15, 2009 yea thats where i added it. not working Link to comment https://forums.phpfreaks.com/topic/149491-include-files-in-php-class/#findComment-785063 Share on other sites More sharing options...
ram4nd Posted March 15, 2009 Share Posted March 15, 2009 Then we can't help if you wont give us contents of those files. Link to comment https://forums.phpfreaks.com/topic/149491-include-files-in-php-class/#findComment-785071 Share on other sites More sharing options...
Daniel0 Posted March 15, 2009 Share Posted March 15, 2009 Look up the word "scope" in the manual. You need to pass the $config array to your object. Link to comment https://forums.phpfreaks.com/topic/149491-include-files-in-php-class/#findComment-785072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.