简体   繁体   中英

phpseclib new NET_SSH2 does not work

i want to use the phpseclib in my project. If I test it in a single way, it works all fine. But when i put it in my sourcecode the sreen is blank.

Here is the part of the code:

<?php
namespace data;

spl_autoload_extensions('.php');
spl_autoload_register();

session_start();

//set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');

require '/phpseclib/Net/SSH2.php';
$ssh = new Net_SSH2('localhost'); // this will not work?

?>

I work with namespace. When i load SSH2.php with require it works all fine. But at the point i open it with $ssh = new Net_SSH2('localhost'); the code crashed and the screen is blank.

Currently i got the following error:

Fatal error: Uncaught exception 'LogicException' with message 'Class Math_BigInteger could not be loaded' in /var/www/test/phpseclib/Net/SSH2.php:857 Stack trace: #0 [internal function]: spl_autoload('Math_BigInteger') #1 /var/www/test/phpseclib/Net/SSH2.php(857): class_exists('Math_BigInteger') #2 /var/www/test/index.php(15): Net_SSH2->Net_SSH2('localhost') #3 {main} thrown in /var/www/test/phpseclib/Net/SSH2.php on line 857

This is the actually code:

namespace data;

error_reporting(E_ALL);

ini_set("display_errors", 1);

spl_autoload_extensions('.php');

spl_autoload_register();

session_start();

set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib'); 

require 'phpseclib/Net/SSH2.php';

$ssh = new \Net_SSH2('localhost');

The screen is probably blank because you have display_errors set to 1. If you do ini_set('display_errors', 1); at the top of your PHP file you'll probably start seeing errors.

In lieu of knowing what errors you're getting I'd wager to guess that you need to do \\Net_SSH2 instead of Net_SSH2 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM