subzerostudio Posted September 11, 2006 Share Posted September 11, 2006 I'm having an unexpected problem with PHP.. I am simply trying to assign a variable!This line works:[code]echo $order->delivery['city'];[/code] output: BRISTOLThis line DOES NOT work:[code]$city = $order->delivery['city'];echo $city;[/code] output: NOTHINGAny ideas why?Mike Quote Link to comment https://forums.phpfreaks.com/topic/20388-simple-php-problem/ Share on other sites More sharing options...
obsidian Posted September 11, 2006 Share Posted September 11, 2006 are you doing both of those on the same page? my question is, on the second example, are you instantiating the $order object before you try to access it? Quote Link to comment https://forums.phpfreaks.com/topic/20388-simple-php-problem/#findComment-89777 Share on other sites More sharing options...
ober Posted September 11, 2006 Share Posted September 11, 2006 You'd almost have to show us the class since that isn't standard PHP. Normally that should work fine. Quote Link to comment https://forums.phpfreaks.com/topic/20388-simple-php-problem/#findComment-89780 Share on other sites More sharing options...
subzerostudio Posted September 11, 2006 Author Share Posted September 11, 2006 [quote author=obsidian link=topic=107644.msg432060#msg432060 date=1157982081]are you doing both of those on the same page? my question is, on the second example, are you instantiating the $order object before you try to access it?[/quote]Yes I am.. I can place the statements directly after each other on the same page.The class is part of the osCommerce package. So I don't think posting the class would be wise, as it would involve posting a few thousand lines of code of a couple of different classes..or maybe I should? hmm.. I'm not *that* confident with PHP, but i expected that to work! ??? Quote Link to comment https://forums.phpfreaks.com/topic/20388-simple-php-problem/#findComment-89789 Share on other sites More sharing options...
Jenk Posted September 11, 2006 Share Posted September 11, 2006 var_dump($city); and show us the output. Quote Link to comment https://forums.phpfreaks.com/topic/20388-simple-php-problem/#findComment-89791 Share on other sites More sharing options...
subzerostudio Posted September 11, 2006 Author Share Posted September 11, 2006 var_dump returns nothing as well.. Maybe if i put it in context that will help:[code]// class methods function quote($method = '') { global $order; //GET THE CITY HERE $city = $order->delivery['city']; $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => $city, 'cost' => MODULE_SHIPPING_FLAT_COST))); if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); return $this->quotes; }[/code]In the above case, 'title' is blank when returned. However if i subsitute this line:[code]'title' => $city,[/code]For this:[code]$order->delivery['city'][/code]It works.?? Quote Link to comment https://forums.phpfreaks.com/topic/20388-simple-php-problem/#findComment-89805 Share on other sites More sharing options...
Jenk Posted September 11, 2006 Share Posted September 11, 2006 var_dump() won't return nothing, it always returns something even if it is just NULL.var_dump($order->delivery['city']); to see what that returns.. Quote Link to comment https://forums.phpfreaks.com/topic/20388-simple-php-problem/#findComment-89810 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.