wolves Posted August 21, 2007 Share Posted August 21, 2007 <?php class defaultItemMenu { var $obj,$name,$link; function __construct($name,$link,$image,$args) { $img = ($image) ? image($image) : ''; $this->name = $name; if($link) { $link = ($args) ? _link(array( 'href' => '#', 'onclick' => "javascript:open_win('".$link."','".$args[0]."','".$args[1]."')"),$this->getName()) : _link(array('href' => $link),$this->getName()); } else $link = ''; if($link) $this->obj = '<li>' . $img . $link. '</li>'; elseif(!$this->getName()) $this->obj = '<li></li>'; else $this->obj = '<li>'.$this->getName().'</li>'; $this->link = $link; } function getName() { //não é um menu comum if(strstr($this->name,'<div')) return $this->name; else return str_replace('_','',$this->name); } function getLink() { return $this->link; } function toString() { return $this->obj; } } class rootItemMenu { var $childs = array(); var $name,$image; function __construct($name,$image) { $this->name = $name; $this->image = $image; } function addDefaultItem($name = null,$link = null,$image = null,$arg = array()) { $this->childs[$this->name][] = &new defaultItemMenu($name,$link,$image,$arg); } function addRootItem($name = null,$image = null) { $obj = &new rootItemMenu($name,$image); $this->childs[$this->name][] = $obj; return $obj; } } class rootMenu { var $defaultItens,$rootItens,$objects = array(); var $name,$link; function __construct($name,$link) { $this->name = $name; $this->link = $link; } function addRootItem($name,$image=null) { $this->rootItens[$name] = $obj = &new rootItemMenu($name,$image); $this->objects[] = $obj; return $obj; } function addDefaultItem($name =null,$link = null,$image = null,$arg = array()) { $this->defaultItens[] = $obj = &new defaultItemMenu($name,$link,$image,$arg); $this->objects[] = $obj; } function addSeparator() { $this->addDefaultItem(); } } class Menu { var $objects; function addRoot($name,$link = null) { $this->objects[] = $obj = &new rootMenu($name,$link); return $obj; } function toString() { $output = ''; foreach($this->objects as $objects) { $link = ($objects->link) ? _link(array('href' => $objects->link),$objects->name) : $objects->name; $output .= "<li> $link"; if($objects->objects) $output .= '<ul>'; foreach($objects->objects as $rootItem) { $output .= self::buildRoots($rootItem); } if($objects->objects) $output.= '</ul>'; $output.= '</li>'; } return '<ul id="_settimainmenu" style="display:none">' . $output . '</ul>'; } private function buildRoots($object) { $output = ''; if(is_a($object,'rootItemMenu')) { $output .= '<li> '; $output .= ($object->image) ? image($object->image) . $object->name : $object->name; $output .= '<ul>'; foreach($object->childs as $rootChilds) { foreach($rootChilds as $child) $output .= self::buildRoots($child); } $output.= '</ul></li>'; return $output; } elseif(is_a($object,'defaultItemMenu')) return $object->toString(); } public static function parseString($str) { $str = str_replace(array( ' ', '_', '/' ),array('','',''),$str); return retiraAcentos('item_'.strtolower($str)); } } ?> using this: <?php $menu = new Menu(); $root = $menu->addRoot('Section 1'); $a = $root->addDefaultItem('Section 1.1'); print '<pre>'; print_r($menu); print '</pre>'; ?> I'm getting 2 different results... localhost: <pre>Menu Object ( [objects] => Array ( [0] => rootMenu Object ( [defaultItens] => Array ( [0] => defaultItemMenu Object ( [obj] => <li>Section 1.1</li> [name] => Section 1.1 [link] => ) ) [rootItens] => [objects] => Array ( [0] => defaultItemMenu Object ( [obj] => <li>Section 1.1</li> [name] => Section 1.1 [link] => ) ) [name] => Section 1 [link] => ) ) ) </pre> other server ( [objects] => Array ( [0] => rootMenu Object ( [defaultItens] => [rootItens] => [objects] => Array ( ) [name] => Section 1 [link] => ) ) ) I Can't fix it... what can be? tks... Quote Link to comment https://forums.phpfreaks.com/topic/65983-different-results-from-different-servers/ Share on other sites More sharing options...
Ninjakreborn Posted August 21, 2007 Share Posted August 21, 2007 It's probably directly related to the php version of the different servers. What are the versions of each (the working one, and the non-working one)? Quote Link to comment https://forums.phpfreaks.com/topic/65983-different-results-from-different-servers/#findComment-329902 Share on other sites More sharing options...
wolves Posted August 21, 2007 Author Share Posted August 21, 2007 working one PHP Version 5.2.0 non-working one PHP Version 5.1.0RC1 Quote Link to comment https://forums.phpfreaks.com/topic/65983-different-results-from-different-servers/#findComment-329931 Share on other sites More sharing options...
Ninjakreborn Posted August 30, 2007 Share Posted August 30, 2007 Then chances are there was one minor change in that version that prevents it from working. Also check for bugs on php.net. Quote Link to comment https://forums.phpfreaks.com/topic/65983-different-results-from-different-servers/#findComment-337850 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.