Какую ошибку этого кода?


Какая ошибка в этом коде?

( ! ) Parse error: syntax error, unexpected '$obj' (T_VARIABLE), expecting function (T_FUNCTION) in C:\wamp\www\php\index.php on line 53

<?php

class Aluga {

public $nome;
public $snome;
public $cpf;
public $rg;
public $tel;
public $email;
public $status;
public $datainicio;
public $datafim;
public $qntpessoas;

function __construct($nome,$snome,$cpf,$rg,$tel,$email,$datainicio,$datafim,$qntpessoas){

$this->nome = $nome;
$this->snome = $snome;
$this->cpf = $cpf;
$this->rg = $rg;
$this->tel = $tel;
$this->email = $email;
$this->status = 0;
$this->datainicio = $datainicio;
$this->datafim = $datafim;
$this->qntpessoas = $qntpessoas;
}

function enviarDados(){

    $sql = 'INSERT INTO `alugueis`(`nome`, `snome`, `cpf`, `rg`, `tel`, `email`, `status`, `datainicio`, `datafim`, `qntpessoas`) VALUES (?,?,?,?,?,?,?,?,?,?)';

    $pdo = new PDO("mysql:host=localhost;dbname=test;","root", "");

    $stmt = $pdo->prepare($sql);

    $stmt->bindValue(1, $this->nome);
    $stmt->bindValue(2, $this->snome);
    $stmt->bindValue(3, $this->cpf);
    $stmt->bindValue(4, $this->rg);
    $stmt->bindValue(5, $this->tel);
    $stmt->bindValue(6, $this->email);
    $stmt->bindValue(7, $this->status);
    $stmt->bindValue(8, $this->datainicio);
    $stmt->bindValue(9, $this->datafim);
    $stmt->bindValue(10, $this->qntpessoas);

    $stmt->execute();
}


$obj = new Aluga("1","2","3","4","5","7","8","9","10");
$obj->enviarDados();


?>
Author: stderr, 2015-05-09

1 answers

Вы забыли закрыть отверстие класса, отсутствует } в конце.

<?php

class Aluga {
    public $nome;
    public $snome;
    public $cpf;
    public $rg;
    public $tel;
    public $email;
    public $status;
    public $datainicio;
    public $datafim;
    public $qntpessoas;

    function __construct($nome,$snome,$cpf,$rg,$tel,$email,$datainicio,$datafim,$qntpessoas){
        $this->nome = $nome;
        $this->snome = $snome;
        $this->cpf = $cpf;
        $this->rg = $rg;
        $this->tel = $tel;
        $this->email = $email;
        $this->status = 0;
        $this->datainicio = $datainicio;
        $this->datafim = $datafim;
        $this->qntpessoas = $qntpessoas;
    }

    function enviarDados(){
        $sql = 'INSERT INTO `alugueis`(`nome`, `snome`, `cpf`, `rg`, `tel`, `email`, `status`, `datainicio`, `datafim`, `qntpessoas`) VALUES (?,?,?,?,?,?,?,?,?,?)';
        $pdo = new PDO("mysql:host=localhost;dbname=test;","root", "");
        $stmt = $pdo->prepare($sql);

        $stmt->bindValue(1, $this->nome);
        $stmt->bindValue(2, $this->snome);
        $stmt->bindValue(3, $this->cpf);
        $stmt->bindValue(4, $this->rg);
        $stmt->bindValue(5, $this->tel);
        $stmt->bindValue(6, $this->email);
        $stmt->bindValue(7, $this->status);$stmt->bindValue(8, $this->datainicio);$stmt->bindValue(9, $this->datafim);$stmt->bindValue(10, $this->qntpessoas);

        $stmt->execute();
    }
}

$obj = new Aluga("1","2","3","4","5","7","8","9","10");
$obj->enviarDados();
?>
 0
Author: stderr, 2015-05-09 21:00:43