Parse error: syntax error, unexpected '{', expecting identifier (T_STRING) in ".. \ index.php" on line 6

0

First of all thanks for your answers, my problem is this.

I am trying to create a file with classes to perform some simple operations, the project folder contains an index and two files contained in a nested folder, but when executing my code I get the following error:

  

Parse error: syntax error, unexpected '{', expecting identifier (T_STRING) in ".. \ index.php" on line 6.

// File index.php ... Directory: 'C: \ xampp \ htdocs \ PHP Course \ Poo \ Classes'

<?php

require_once 'libs/Matematica/Aritmetica.php';
require_once 'libs/Matematica/Financiera.php';

use libs\Matematica\{Aritmetica, Financiera};

$obj = New Financiera(1000, 0.25 , 1);
$obj1 = new Matematica();

var_dump($obj->tea());


var_dump($obj1->suma(2,3));


?>

// File Arithmetic.php Directory: 'C: \ xampp \ htdocs \ PHP Course \ Poo \ Classes \ libs \ mathematics'

<?php
namespace libs\Matematica;

class Aritmetica {

    public function suma(float $a, float $b) : float {
        return $a + $b; 
    }

    public function resta(float $a, float $b) : float {
        return $a - $b; 
    }

    public function multiplicacion(float $a, float $b) : float {
        return $a * $b; 
    }

    public function division(float $a, float $b) : float {
        return $a / $b; 
    }

    public function EsPar(float $n){

        return $this->calcularParoImpar($n);
    }

    public function EsImpar(float $n){
        return $this->calcularParoImpar($n, false);
    }

    private function CalcularParoImpar(float $n, bool $par = true ) : bool {
        if ($par) {
            return $n % 2 === 0; 
        } else {
            return $n % 2 !== 0;
        }
    }
}

?>

// Financial File.php Directory: 'C: \ xampp \ htdocs \ PHP Course \ Poo \ Classes \ libs \ mathematics'

<?php
namespace Libs\Matematica;

class Financiera {
    #Propiedades
     private $capital;
     private $tasa;
     private $periodo;

    public function __construct(
        float $capital,
        float $tasa,
        int $periodo
    ) {
        this->capital = $capital;
        this->tasa = $tasa;
        this->periodo = $periodo;   
    }

    function __destruct() {
        echo 'Ha finalizado el calculo para financiera';
    }

    public function tea () : float {
        return this->capital *((1 + this->$tasa) ** this->$periodo);
    }
}
?>
    
asked by Mario Ibarra 30.05.2018 в 05:21
source

0 answers