Parse error: syntax error, unexpected T_STRIN

Bonjour,
j'ai une erreur mais je n'arrive pas a la résoudre :
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homez.***/******/www/******/*******/****/****/****.php on line 27

le line 27 est private $x;
et le code complete

<?php
/* Libchart - PHP chart library
* Copyright (C) 2005-2008 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* Point of coordinates (X,Y).
* The value of X isn't really of interest, but X is used as a label to display on the horizontal axis.
*
* @author Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
*/
class Point {
private $x;
private $y;

/**
* Creates a new sampling point of coordinates (x, y)
*
* @param integer x coordinate (label)
* @param integer y coordinate (value)
*/
public function Point($x, $y) {
$this->x = $x;
$this->y = $y;
}

/**
* Gets the x coordinate (label).
*
* @return integer x coordinate (label)
*/
public function getX() {
return $this->x;
}

/**
* Gets the y coordinate (value).
*
* @return integer y coordinate (value)
*/
public function getY() {
return $this->y;
}
}
?>

6 réponses

  1. Bonjour,

    Quelle version de php utilises-tu ? Les mots clé de visibilité (« private », « public », « protected ») on été introduit en php 5. Donc si tu es sous php4, remplace-les par « var »

    Xavier
    0
    1. Bonjour,
      merci de votre réponse rapide
      j'utilise php4 et comme vous m'avez expliqué j'ai changé « private », « public », « protected » en var mais maintenant
      l'erreur affichée est :

      Parse error: syntax error, unexpected T_FUNCTION, expecting T_VARIABLE in /****.***/***/www/*****/****/****/****/****.php on line 36

      la ligne 36 est :
      var function Point($x, $y) {

      et le code complet est :

      <?php
      /* Libchart - PHP chart library
      * Copyright (C) 2005-2008 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
      *
      * This program is free software: you can redistribute it and/or modify
      * it under the terms of the GNU General Public License as published by
      * the Free Software Foundation, either version 3 of the License, or
      * (at your option) any later version.
      *
      * This program is distributed in the hope that it will be useful,
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      * GNU General Public License for more details.
      *
      * You should have received a copy of the GNU General Public License
      * along with this program. If not, see <http://www.gnu.org/licenses/>.
      *
      */

      /**
      * Point of coordinates (X,Y).
      * The value of X isn't really of interest, but X is used as a label to display on the horizontal axis.
      *
      * @author Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
      */
      class Point {
      var $x;
      var $y;

      /**
      * Creates a new sampling point of coordinates (x, y)
      *
      * @param integer x coordinate (label)
      * @param integer y coordinate (value)
      */
      var function Point($x, $y) {
      $this->x = $x;
      $this->y = $y;
      }

      /**
      * Gets the x coordinate (label).
      *
      * @return integer x coordinate (label)
      */
      var function getX() {
      return $this->x;
      }

      /**
      * Gets the y coordinate (value).
      *
      * @return integer y coordinate (value)
      */
      var function getY() {
      return $this->y;
      }
      }
      ?>

      merci d'avance pour votre aide
      0
      1. Ah, c'est ma faute, je n'avais pas tout lu.
        Les var doivent être mis devant les déclarations de variables (var $x;).
        Devant les déclarations de fonction, il ne faut rien mettre.
        Donc
        « var function Point($x, $y) { »
        devient
        « function Point($x, $y) { »

        Désolé du contre-temps...

        Xavier
        0
        1. merci encore pour votre réponse rapide.
          Je suis pas sorti de l'auberge parce que j'ai encore des problèmes dans les autre fichiers comme :

          Parse error: syntax error, unexpected T_VAR in /****.***/***/www/*****/****/****/****/****.php on line 58
          et la ligne est:

          if ($dataSet instanceof XYDataSet) {

          et les codes sont :

          <?php
          /* Libchart - PHP chart library
          * Copyright (C) 2005-2008 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
          *
          * This program is free software: you can redistribute it and/or modify
          * it under the terms of the GNU General Public License as published by
          * the Free Software Foundation, either version 3 of the License, or
          * (at your option) any later version.
          *
          * This program is distributed in the hope that it will be useful,
          * but WITHOUT ANY WARRANTY; without even the implied warranty of
          * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          * GNU General Public License for more details.
          *
          * You should have received a copy of the GNU General Public License
          * along with this program. If not, see <http://www.gnu.org/licenses/>.
          *
          */

          /**
          * Object representing the bounds of a dataset (its minimal and maximal values) on its vertical axis.
          * The bounds are automatically calculated from a XYDataSet or XYSeriesDataSet.
          * Default (calculated) bounds can be overriden using the setLowerBound() and setUpperBound() methods.
          *
          * @author Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
          * Created on 25 july 2007
          */
          class Bound {
          /**
          * Manually set lower bound, overrides the value calculated by computeBound().
          */
          var $lowerBound = null;

          /**
          * Manually set upper bound, overrides the value calculated by computeBound().
          */
          var $upperBound = null;

          /**
          * Computed min bound.
          */
          var $yMinValue = null;

          /**
          * Computed max bound.
          */
          var $yMaxValue = null;

          /**
          * Compute the boundaries on the axis.
          *
          * @param dataSet The data set
          */
          function computeBound($dataSet) {
          // Check if the data set is empty
          $dataSetEmpty = true;
          $serieList = null;
          var if ($dataSet instanceof XYDataSet) {
          $pointList = $dataSet->getPointList();
          $dataSetEmpty = count($pointList) == 0;

          if (!$dataSetEmpty) {
          // Process it as a serie
          $serieList = array();
          array_push($serieList, $dataSet);
          }
          } else if ($dataSet instanceof XYSeriesDataSet) {
          $serieList = $dataSet->getSerieList();
          if (count($serieList) > 0) {
          $serie = current($serieList);
          $dataSetEmpty = count($serie) == 0;
          }
          } else {
          die("Error: unknown dataset type");
          }

          // If the dataset is empty, default some bounds
          $yMin = 0;
          $yMax = 1;
          if (!$dataSetEmpty) {
          // Compute lower and upper bound on the value axis
          unset($yMin);
          unset($yMax);

          foreach ($serieList as $serie) {
          foreach ($serie->getPointList() as $point) {
          $y = $point->getY();

          if (!isset($yMin)) {
          $yMin = $y;
          $yMax = $y;
          } else {
          if ($y < $yMin) {
          $yMin = $y;
          }

          if ($y > $yMax) {
          $yMax = $y;
          }
          }
          }
          }
          }

          // If user specified bounds and they are actually greater than computer bounds, override computed bounds
          if (isset($this->lowerBound) && $this->lowerBound < $yMin) {
          $this->yMinValue = $this->lowerBound;
          } else {
          $this->yMinValue = $yMin;
          }

          if (isset($this->upperBound) && $this->upperBound > $yMax) {
          $this->yMaxValue = $this->upperBound;
          } else {
          $this->yMaxValue = $yMax;
          }
          }

          /**
          * Getter of yMinValue.
          *
          * @return min bound
          */
          function getYMinValue() {
          return $this->yMinValue;
          }

          /**
          * Getter of yMaxValue.
          *
          * @return max bound
          */
          function getYMaxValue() {
          return $this->yMaxValue;
          }

          /**
          * Set manually the lower boundary value (overrides the automatic formatting).
          * Typical usage is to set the bars starting from zero.
          *
          * @param double lower boundary value
          */
          function setLowerBound($lowerBound) {
          $this->lowerBound = $lowerBound;
          }

          /**
          * Set manually the upper boundary value (overrides the automatic formatting).
          *
          * @param double upper boundary value
          */
          function setUpperBound($upperBound) {
          $this->upperBound = $upperBound;
          }
          }
          ?>

          merci encore pour votre aide et je pense que je vais encore poser des questions sur ce probleme.
          cordialement

          kris
          0
          1. Bon, là, je pense qu'il va falloir prendre le problème à l'envers.
            Manifestement, tu utilises un script écrit pour php5, et si on doit tout rendre compatible php4, on n'est pas sorti.

            Est-ce que tu ne pourrais pas plutôt mettre à jour ton serveur php ?

            Xavier
            0
            1. Bonjour, merci encore pour votre réponse

              Mon serveur est compatible php5
              j'ai remis tout les fichiers sur le serveur, mais j'ai toujours le même problème.

              Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homez.***/******/www/******/*******/****/****/****.php on line 27

              le line 27 est private $x;

              et le code complet est:

              <?php
              /* Libchart - PHP chart library
              * Copyright (C) 2005-2008 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
              *
              * This program is free software: you can redistribute it and/or modify
              * it under the terms of the GNU General Public License as published by
              * the Free Software Foundation, either version 3 of the License, or
              * (at your option) any later version.
              *
              * This program is distributed in the hope that it will be useful,
              * but WITHOUT ANY WARRANTY; without even the implied warranty of
              * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
              * GNU General Public License for more details.
              *
              * You should have received a copy of the GNU General Public License
              * along with this program. If not, see <http://www.gnu.org/licenses/>.
              *
              */

              /**
              * Point of coordinates (X,Y).
              * The value of X isn't really of interest, but X is used as a label to display on the horizontal axis.
              *
              * @author Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
              */
              class Point {
              private $x;
              private $y;

              /**
              * Creates a new sampling point of coordinates (x, y)
              *
              * @param integer x coordinate (label)
              * @param integer y coordinate (value)
              */
              public function Point($x, $y) {
              $this->x = $x;
              $this->y = $y;
              }

              /**
              * Gets the x coordinate (label).
              *
              * @return integer x coordinate (label)
              */
              public function getX() {
              return $this->x;
              }

              /**
              * Gets the y coordinate (value).
              *
              * @return integer y coordinate (value)
              */
              public function getY() {
              return $this->y;
              }
              }
              ?>

              est ce que vous pouvez m'expliquer d'ou vient le problème, je n'y comprends plus rien.
              Merci de votre aide
              cordialement
              kris
              0