turing_machine Posted October 25, 2011 Share Posted October 25, 2011 Hi, I am running a web server for which I place the php files in /var/www folder and they work fine from the browser. Now, I wish to use SSH2 class that can be found at (http://phpseclib.sourceforge.net/documentation/net.html#net_ssh_ssh2). I have placed SSH2.php in the same folder (/var/www) but it doesn't work. I have also copied the file in /usr/share/php (which is the path returned by ini_get('include_path') command). Where do I put my required file (SSH2.php) so that I can use it. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/249766-how-to-include-other-classes/ Share on other sites More sharing options...
trq Posted October 25, 2011 Share Posted October 25, 2011 If the file is on your include_path you just need to include it. include 'SSH2.php'; Quote Link to comment https://forums.phpfreaks.com/topic/249766-how-to-include-other-classes/#findComment-1282009 Share on other sites More sharing options...
turing_machine Posted October 25, 2011 Author Share Posted October 25, 2011 That does not work. Trying the following, <?php include 'SSH2.php'; echo "Successful"; ?> Google chrome gives "Server Error". Quote Link to comment https://forums.phpfreaks.com/topic/249766-how-to-include-other-classes/#findComment-1282012 Share on other sites More sharing options...
Buddski Posted October 25, 2011 Share Posted October 25, 2011 What is the HTTP status code? (500 etc etc) Is PHP throwing any errors saying that the file could not be included? if (include('SSH2.php')) { echo 'Success'; } else { echo 'Fail on include.'; } Quote Link to comment https://forums.phpfreaks.com/topic/249766-how-to-include-other-classes/#findComment-1282018 Share on other sites More sharing options...
trq Posted October 25, 2011 Share Posted October 25, 2011 @Buddski include does not return true or false on success or failure. @op It also does not throw any error if it fails. You have other issues with your server. What does the error log have to say? Quote Link to comment https://forums.phpfreaks.com/topic/249766-how-to-include-other-classes/#findComment-1282028 Share on other sites More sharing options...
Buddski Posted October 25, 2011 Share Posted October 25, 2011 @Buddski include does not return true or false on success or failure. Does on my servers If the file can't be included, FALSE is returned and E_WARNING is issued. Quote Link to comment https://forums.phpfreaks.com/topic/249766-how-to-include-other-classes/#findComment-1282032 Share on other sites More sharing options...
trq Posted October 25, 2011 Share Posted October 25, 2011 Ha, well there is one I obviously forgot about. I generally use require because I want my scripts to fail if any dependencies aren't found, I assumed include failed silently. Quote Link to comment https://forums.phpfreaks.com/topic/249766-how-to-include-other-classes/#findComment-1282058 Share on other sites More sharing options...
mozillaen Posted October 28, 2011 Share Posted October 28, 2011 phpseclib expects you to include Net/SSH2.php - not SSH2.php directly. To top it off SSH2.php has dependencies. It expects Math/BigInteger.php to be present, etc. Quote Link to comment https://forums.phpfreaks.com/topic/249766-how-to-include-other-classes/#findComment-1282882 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.