Unexpected T_STRING, expecting '{'
DoyoB
-
DoyoB -
DoyoB -
Bonjour,
Une erreur apparai dans mon script et impossible de trouver ou :
Parse error: syntax error, unexpected T_STRING, expecting '{' in /homez.429/danslaru/www/modules/mod_roknavmenu/lib/librokmenu/RokMenuNodeBase.php on line 16
voila mon code quelqu'un aurai t'il la solution ? :
<?php
/**
* @version 2.1 October 7, 2010
* @author RocketTheme http://www.rockettheme.com
* @copyright Copyright (C) 2007 - 2010 RocketTheme, LLC
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/
require_once(dirname(__FILE__) . '/RokMenuIterator.php');
if (!class_exists('RokMenuNodeBase')) {
/**
*
*/
class RokMenuNodeBase implements IteratorAggregate {
function getIterator() {
return new RokMenuIterator($this);
}
/**
* @var int
*/
protected $id = 0;
/**
* @var int
*/
protected $parent = 0;
/**
* @var RokMenuNodeBase
*/
protected $parentRef = null;
/**
* @var int
*/
protected $level = -1;
/**
* @var array
*/
protected $children = array();
/**
* Gets the id
* @access public
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* Sets the id
* @access public
* @param integer $id
*/
public function setId($id) {
$this->id = $id;
}
/**
* Gets the level
* @access public
* @return integer
*/
public function getLevel() {
return $this->level;
}
/**
* Sets the level
* @access public
* @param integer $level
*/
public function setLevel($level) {
$this->level = $level;
}
/**
* Gets the parent
* @access public
* @return integer
*/
public function getParent() {
return $this->parent;
}
/**
* Sets the parent
* @access public
* @param integer $parent
*/
public function setParent($parent) {
$this->parent = $parent;
}
/**
* @return RokMenuNodeBase
*/
public function getParentRef() {
return $this->parentRef;
}
/**
* @param RokmenuNodeBase $parentRef
* @return void
*/
public function setParentRef(RokmenuNodeBase & $parentRef) {
$this->parentRef = &$parentRef;
}
/**
* @param $children
* @return void
*/
public function setChildren(array $children) {
$this->children = $children;
}
/**
* @param RokMenuNodeBase $node
* @return void
*/
public function addChild(RokMenuNodeBase &$node) {
if (null == $this->children) {
$this->children = array();
}
$node->setParentRef($this);
$node->setLevel($this->getLevel()+1);
$this->children[$node->getId()] = $node;
}
/**
* @return bool
*/
public function hasChildren() {
return (count($this->children)>0)?true:false;
}
/**
* @return array
*/
public function &getChildren() {
return $this->children;
}
/**
* @param $node_id
* @return bool
*/
public function removeChild($node_id) {
if (array_key_exists($node_id, $this->children)) {
unset($this->children[$node_id]);
return true;
}
return false;
}
}
}
Une erreur apparai dans mon script et impossible de trouver ou :
Parse error: syntax error, unexpected T_STRING, expecting '{' in /homez.429/danslaru/www/modules/mod_roknavmenu/lib/librokmenu/RokMenuNodeBase.php on line 16
voila mon code quelqu'un aurai t'il la solution ? :
<?php
/**
* @version 2.1 October 7, 2010
* @author RocketTheme http://www.rockettheme.com
* @copyright Copyright (C) 2007 - 2010 RocketTheme, LLC
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/
require_once(dirname(__FILE__) . '/RokMenuIterator.php');
if (!class_exists('RokMenuNodeBase')) {
/**
*
*/
class RokMenuNodeBase implements IteratorAggregate {
function getIterator() {
return new RokMenuIterator($this);
}
/**
* @var int
*/
protected $id = 0;
/**
* @var int
*/
protected $parent = 0;
/**
* @var RokMenuNodeBase
*/
protected $parentRef = null;
/**
* @var int
*/
protected $level = -1;
/**
* @var array
*/
protected $children = array();
/**
* Gets the id
* @access public
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* Sets the id
* @access public
* @param integer $id
*/
public function setId($id) {
$this->id = $id;
}
/**
* Gets the level
* @access public
* @return integer
*/
public function getLevel() {
return $this->level;
}
/**
* Sets the level
* @access public
* @param integer $level
*/
public function setLevel($level) {
$this->level = $level;
}
/**
* Gets the parent
* @access public
* @return integer
*/
public function getParent() {
return $this->parent;
}
/**
* Sets the parent
* @access public
* @param integer $parent
*/
public function setParent($parent) {
$this->parent = $parent;
}
/**
* @return RokMenuNodeBase
*/
public function getParentRef() {
return $this->parentRef;
}
/**
* @param RokmenuNodeBase $parentRef
* @return void
*/
public function setParentRef(RokmenuNodeBase & $parentRef) {
$this->parentRef = &$parentRef;
}
/**
* @param $children
* @return void
*/
public function setChildren(array $children) {
$this->children = $children;
}
/**
* @param RokMenuNodeBase $node
* @return void
*/
public function addChild(RokMenuNodeBase &$node) {
if (null == $this->children) {
$this->children = array();
}
$node->setParentRef($this);
$node->setLevel($this->getLevel()+1);
$this->children[$node->getId()] = $node;
}
/**
* @return bool
*/
public function hasChildren() {
return (count($this->children)>0)?true:false;
}
/**
* @return array
*/
public function &getChildren() {
return $this->children;
}
/**
* @param $node_id
* @return bool
*/
public function removeChild($node_id) {
if (array_key_exists($node_id, $this->children)) {
unset($this->children[$node_id]);
return true;
}
return false;
}
}
}
A voir également:
- Syntax error, unexpected 'string' (t_string), expecting function (t_function) or const (t_const)
- Or - Guide
- Eespt technical error ✓ - Forum TNT / Satellite / Réception
- Carre or bercy ✓ - Forum Loisirs / Divertissements
- Cannot access offset of type string on string - Forum PHP
- X64 or x86 ✓ - Forum Windows
2 réponses
Bonjour,
Ton fichier est bien terminé par la balise fermante PHP ?> car on ne la voit pas en fin de ton script...
Ton fichier est bien terminé par la balise fermante PHP ?> car on ne la voit pas en fin de ton script...
Je ne suis pas sur qu'on puisse mettre une classe comme ça dans une condition (ce qui expliquerait l'erreur à la ligne 16). Si je comprends bien ce que tu cherches à faire je changerais plutôt ma condition (en enlevant le "!") et en mettant un "return" à l'intérieur. Ainsi si la class est déjà connu on ne lit pas la suite.
Donc quelque chose du genre:
if (class_exists('RokMenuNodeBase')) { return 1; }
class RokMenuNodeBase implements IteratorAggregate {
...
...
...
}
Donc quelque chose du genre:
if (class_exists('RokMenuNodeBase')) { return 1; }
class RokMenuNodeBase implements IteratorAggregate {
...
...
...
}
<?php
/**
* @version 2.1 October 7, 2010
* @author RocketTheme http://www.rockettheme.com
* @copyright Copyright (C) 2007 - 2010 RocketTheme, LLC
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/
class RokMenuIterator implements RecursiveIterator
{
protected $ar;
public function __construct(RokMenuNodeBase $menuNode)
{
$this->ar = & $menuNode->getChildren();
}
public function rewind()
{
reset($this->ar);
}
public function valid()
{
return !is_null(key($this->ar));
}
public function key()
{
return key($this->ar);
}
public function next()
{
next($this->ar);
}
public function current()
{
return current($this->ar);
}
public function hasChildren()
{
$current = current($this->ar);
return $current->hasChildren();
}
public function getChildren()
{
return new RokMenuIterator($this->current());
}
}