您好我正在使用以下代码来显示表格,但它会显示如下错误。
Warning: require(HTML/Table.php) [function.require]: failed to open stream: No such file or directory in /home/aspire/public_html/table.php on line 3
Fatal error: require() [function.require]: Failed opening required 'HTML/Table.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/aspire/public_html/table.php on line 3
这是我的代码。谁能告诉我我做了什么错误。
require("HTML/Table.php");
$tableStyle = array("bgcolor"=>"#FFFFFF", "border"=>"1", "width"=>"150", "cellpadding"=>"1", "cellspacing"=>"2");
$colA = array("field 1", "field 2", "field 3", "", "<b>TOTAL</b>");
$a = 10;
$b = 15;
$c = 8;
$total = $a+$b+$c;
$colB = array($a, $b, $c, "", "<b>".$total."</b>");
$table = new HTML_Table($tableStyle);
$table->addCol($colA);
$table->addCol($colB);
$table->display();
使用这个“ php go-pear.phar ”命令,我找到了以下路径。
Current include path : .:/usr/share/php:/usr/share/pear
Configured directory : /home/aspire/pear/share/pear
Currently used php.ini (guess) : /etc/php5/cli/php.ini
所以在开始我的代码之前指定路径,比如
include_path=".:/usr/share/php:/usr/share/pear/";
它显示错误,如
Parse error: syntax error, unexpected '=' in /home/aspire/public_html/table.php on line 2
如何解决这个问题。
答案 0 :(得分:1)
尝试示例代码,我收到错误消息:
PHP Warning: require(HTML/Table.php): failed to open stream: No such file or directory in /home/dylan/Desktop/scratch/pear_path.php on line 3
PHP Fatal error: require(): Failed opening required 'HTML/Table.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/dylan/Desktop/scratch/pear_path.php on line 3
我解决了这个问题,并且该程序在执行完成后似乎工作正常:
sudo pear install HTML_Table
如果您遇到问题包版本,可以尝试使用pear force选项。
sudo pear install -f --alldeps HTML_Table
答案 1 :(得分:0)
设置包含路径的正确方法是:
set_include_path(".:/usr/share/php:/usr/share/pear/");