Php 5.3 Parse Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company syntax error unexpected in php Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs php unexpected semicolon Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, php parse error syntax error unexpected t_variable just like you, helping each other. Join them; it only takes a minute: Sign up Parse error: syntax error, unexpected '[' with php 5.3 [duplicate] up vote 12 down vote favorite 3 This question already has an
Php Parse Error Syntax Error Unexpected Expecting
answer here: PHP syntax for dereferencing function result 21 answers My script is working really fine on my xampp. Now I tried to upload it on the server, but it spat directly a Parse error: syntax error, unexpected '[' in my face. :( The line which its mocking about is this one: $item = $xml->xpath($path)[0]; And I have no idea what is wrong. I tried to look on the php 5.3 changelog but did syntax error unexpected codeigniter not found anything about it. (Because I have 5.3 on the server, and on xampp its an olderversion) The whole code block looks like this: $path = '//item[@id="'.$id.'"]'; if ($xml->xpath($path)) { $item = $xml->xpath($path)[0]; } else { die('
Script Error: Code 101 - Please contact administrator
'); } I am thankful for any help, I cannot seach [ with google and have no idea where it could come from, since on xampp its working fine php php-5.3 parse-error share|improve this question edited May 3 '13 at 12:33 Felix Kling 394k81619664 asked May 3 '13 at 12:30 Owl 38921024 marked as duplicate by Gordon May 3 '13 at 12:34 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. 7 you need 5.4 to use it like this. in your case $item = $xml->xpath($path); $item[0]; –Kin May 3 '13 at 12:32 3 "As of PHP 5.4 it is possible to array dereference the result of a function or method call directly. Before it was only possible using a temporary variable." php.net/manual/en/language.types.array.php –Felix Kling May 3 '13 at 12:33 $item = $xml->xpath($path0); i don't know but does this work? –Kees Sonnema May 3 '13 at 12:33 You need to change $item = $xmhere for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies php parse error: syntax error, unexpected '[' array of this site About Us Learn more about Stack Overflow the company Business
Parse Error Syntax Error Unexpected In
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Syntax Error Unexpected Laravel
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/16358973/parse-error-syntax-error-unexpected-with-php-5-3 Sign up PHP 5.3.10 vs PHP 5.5.3 syntax error unexpected '[' up vote 7 down vote favorite Is it possible that this PHP code line if ($this->greatestId()["num_rows"] > 0) works in PHP 5.5 and returns an error in 5.3?? PHP Parse error: syntax error, unexpected '[' in /var/www/app/AppDAO.php on line 43 How can I change it to work under PHP 5.3? php arrays http://stackoverflow.com/questions/23565971/php-5-3-10-vs-php-5-5-3-syntax-error-unexpected php-5.3 dereference php-5.5 share|improve this question edited Jun 18 '14 at 20:53 Sam 4,60972455 asked May 9 '14 at 13:33 dendini 1,16852154 add a comment| 3 Answers 3 active oldest votes up vote 13 down vote Array dereferencing became available in PHP 5.4 That's why this doesn't work in PHP 5.3. So you have an extra step where you need to get the array value from your function call and then you can use it: $variable = $this->greatestId(); if ($variable["num_rows"] > 0){ // do stuff } share|improve this answer answered May 9 '14 at 13:37 John Conde 156k70289364 1 found the link: php.net/manual/en/migration54.new-features.php inside new features they say: Function array dereferencing has been added, e.g. foo()[0]. –dendini May 9 '14 at 13:38 I ran into this error yesterday, on my local env i have php5.5 and on testing 5.3 :/ thanks for answer. –Neok Oct 6 '14 at 6:17 add a comment| up vote 2 down vote You cant use like this if ($this->greatestId()["num_rows"] > 0) in PHP 5.3 ver use below code. $var = $this->greatestId(); if ($var["num_rows"] > 0){ // y
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site http://stackoverflow.com/questions/33420170/parse-error-syntax-error-unexpected-expecting-php About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Parse error: syntax syntax error error, unexpected '[', expecting ')' php up vote -2 down vote favorite I am creating a custom shipping method for opencart, however i am stuck on the catalog model file, which is for PHP 5.4+, but how do i make it working with PHP 5.3 as Opencart Requirement is start from PHP 5.3 catalog/model/shipping/items.php $languages = $this->language->get('code'); $quote_data = array(); $quote_data['items'] = array( 'code' => syntax error unexpected 'items.items', 'title' => $this->config->get('items_shipping_description')[$languages], 'cost' => $this->config->get('items_cost'), 'tax_class_id' => $this->config->get('items_tax_class_id'), 'text' => $this->currency->format($this->tax->calculate($items_cost, $this->config->get('items_tax_class_id'), $this->config->get('config_tax'))) ); this line working fine with PHP 5.4+ but not PHP 5.3 'title'=> $this->config->get('items_shipping_description')[$languages], I get an error for PHP 5.3 which is Parse error: syntax error, unexpected '[', expecting ')' in ... I've also read many duplicate question and tried many different way to make this working with no luck! please help, thank you! php syntax-error opencart share|improve this question edited Oct 29 '15 at 17:15 Devendra Bhandari 496412 asked Oct 29 '15 at 16:49 Zulfakar Zukri 91113 1 first google hit for the title of the question: stackoverflow.com/questions/17411106/… –Karoly Horvath Oct 29 '15 at 16:51 2 Possible duplicate of PHP syntax for dereferencing function result –Karoly Horvath Oct 29 '15 at 16:51 @karoly Horvath: that was the first question i've ever read, btw thank you –Zulfakar Zukri Oct 29 '15 at 16:56 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote accepted Just assign it to variable: $description = $this->config->get('items_shipping_description') And then use: $quote_data['items'] = array( 'code' => 'items.items', 'title' => $description[$languages] 'cost' => $this->config->get('items_cost'), 'ta