Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/03/2015, 10:58
Viturbiko
 
Fecha de Ingreso: septiembre-2014
Mensajes: 72
Antigüedad: 9 años, 8 meses
Puntos: 0
Duda con PEAR

Hola, estoy empezando con PHP, y he descubierto PEAR, que parece bastante útil para incluir algunos scripts.

Pero tengo un problema. Lo he instalado (creo que correctamente), y he instalado también alguno de sus scripts. Aqui tenéis el ejemplo que estoy probando, sacado de un libro que estoy utilizando para aprender:

Cita:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>Fibonacci sequence using HTML_Table</title>
<link rel="stylesheet" type="text/css" href="common.css" />
<style type="text/css">
th { text-align: left; background-color: #999; }
th, td { padding: 0.4em; }
tr.alt td { background: #ddd; }
</style>
</head>

<body>

<h1>Fibonacci sequence using HTML_Table</h1>

<?php

require_once("PEAR/HTML/Table.php");
$attrs = array("cellspacing" => 0, "border" => 0, "style" => "width: 20em; border: 1px solid #666;");
$table = new HTML_Table($attrs);
$table->addRow(array("Sequence #", "Value"), null, "th");

$iterations = 10;

$num = 0;
$num = 1;

$table->addRow(array("F<sub>0</sub>", "0"));
$table->addRow(array("F<sub>1</sub>", "1"));

for ($i=2; $i <= $iterations; $i++) {

$sum = $num1 + $num2;
$num1 = $num2;
$num2 = $sum;
$table->addRow(array("F<sub>$i</sub>", $num2));

?>

<?php

}

$attrs = array("class" => "alt");
$table->altRowAttributes(1,null,$attrs,true);
echo $table->toHtml();

?>

</body>

</html>
Se entiende que es una tabla que muestra una sucesión de fibonacci de varios números. Como podéis ver, en require_once aparece el directorio donde se supone que está Table.php, pues el PEAR que he descargado es Table_HTML. La cuestión es que a la hora de mostrar este archivo en localhost, me aparece el siguiente error:



He abierto el archivo Table.php, y he cambiado el directorio que viene por defecto, que es este:

Cita:
require_once 'PEAR.php';
Por este:

Cita:
require_once '..\PEAR.php';
Que es donde se encuentra el archivo PEAR.php, pero el error me sigue apareciendo...

¿Sabéis que estoy haciendo mal? No se como me puede dar tantos problemas un error que parece tan sencillo...

Muchas gracias y un saludo