Php Syntax Error Unexpected T_function
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 parse error: syntax error, unexpected t_function wordpress company Business Learn more about hiring developers or posting ads with us Stack Overflow parse error: syntax error, unexpected t_function drupal Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2
Parse Error Syntax Error Unexpected T Function Wordpress
million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Parse error: syntax error, unexpected T_FUNCTION line 10 ? help? up vote 13 down vote favorite 1 Hi everyone
T_function Php
can someone please tell me what wrong with my code i ran the code on my test server and the code worked but when i upload it to my production server i get Parse error: syntax error, unexpected T_FUNCTION in /hermes/bosweb/web013/b130/ipg.acrsflcom/darayngedbeats/gentest.php on line 10 here is my code $old = "http://darayngedbeats1.s3.amazonaws.com /mp3/CrazyMonsta2.mp3?AWSAccessKeyId=AKIAJXA36ESCLQHCB54Q&Expires=1297279906& Signature=HD36ZQE8yeTIW6JPWKMcciPTiTs%3D"; //enter the key that needs to be converted $search = array(":","?","=","&","%"); $replace = array("%3A","%3F","%3D","%26","%25"); function search_replace($s,$r,$sql) { $e = '/('.implode('|',array_map('preg_quote', syntax error unexpected t_function usort $s)).')/'; $r = array_combine($s,$r); return preg_replace_callback($e, function($v) use ($s,$r) { return $r[$v[1]]; },$sql); } echo "
"; $new = search_replace($search,$replace,$old); echo $new; ?> php share|improve this question asked Feb 9 '11 at 19:34 acrs 1332313 Which line is line 10? –Daniel A. White Feb 9 '11 at 19:36 what version of php? –Foo Bah Feb 9 '11 at 19:36 i presume it has to do with the callback function –Foo Bah Feb 9 '11 at 19:37 line 7 return preg_replace_callback($e, function($v) use ($s,$r) { return $r[$v[1]]; },$sql); –acrs Feb 9 '11 at 19:39 Q: "Which line is line 10?" - A: "line 7 [code]" I lol'd. –Shoe Feb 9 '11 at 19:51 | show 1 more comment 5 Answers 5 active oldest votes up vote 24 down vote accepted The error is likely caused by return preg_replace_callback($e, function($v) use ($s,$r) { return $r[$v[1]]; },$sql); Chances are you're using PHP 5.2 or earlier, which doesn't support closures. You can find out which version of PHP you're using phpinfo(). You'll likely either need to upgrade to PHP 5.3+, or use create_function, or write a static function and pass it as a callback. Here's an example of the last option, using a simple class to store the state of
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
Parse Error Syntax Error Unexpected Expecting Function T_function
Learn more about Stack Overflow the company Business Learn more about hiring developers parse error: syntax error, unexpected t_function, expecting ')' or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack php function 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 Unexpected T_FUNCTION? up vote 3 down vote http://stackoverflow.com/questions/4949573/parse-error-syntax-error-unexpected-t-function-line-10-help favorite I've question about solving in php version 5.2.7, where i get an error Parse error: syntax error, unexpected T_FUNCTION in /home/ ... /mainMenu.php on line 56. The code is class MainMenu { ... private static function toRec($arr) { ... usort($newArr, function($a, $b) {//this was line 56 return $a['nav_order'] - $b['nav_order']; }); ... } ... } What is alternative for php 5.2? Thank you php share|improve this http://stackoverflow.com/questions/16015286/unexpected-t-function question asked Apr 15 '13 at 12:34 user2274867 2112 Create the function and name it separately, and then call it usort($newArr, 'myFunctionName'); –Jon Apr 15 '13 at 12:35 There are several examples in the usort() docs –Michael Berkowski Apr 15 '13 at 12:35 Welcome to StackOverflow. Your question doesn't give enough of your code to make an authorive answer. However, that error in PHP usually means you haven't properly ended a previous statement with a ;, or other function ending ), etc. Check your statement endings. –PenguinCoder Apr 15 '13 at 12:36 3 @PenguinCoder Unless you know that PHP 5.2 doesn't support anonymous functions. And there is enough there to go off of. –Jon Apr 15 '13 at 12:36 2 @PenguinCoder In this case it is the use of an anonymous function in PHP 5.2, which the OP is aware of. –Michael Berkowski Apr 15 '13 at 12:37 add a comment| 4 Answers 4 active oldest votes up vote 6 down vote As you've discovered, the inline function syntax is only valid in PHP 5.3 an higher. It is not available in PHP 5.2. The alternative is to specify the
» Parse error: syntax error, unexpected 'function' (T_FUNCTION) Parse error: syntax error, unexpected 'function' (T_FUNCTION) Pcosta88 @pcosta88 10 months, 2 weeks ago Theme: Current updated 2013 https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-function-t_function/ Theme WordPress: 4.4 the newest PHP: I assume since I updated to the newest WP it is also updated to the newest PHP Hosting: Local host on http://magento.stackexchange.com/questions/43234/php-parse-error-syntax-error-unexpected-t-function-expect computer using XAMPP. Error: Parse error: syntax error, unexpected ‘function' (T_FUNCTION) in /Applications/XAMPP/xamppfiles/apps/wordpress/htdocs/wp-content/themes/twentythirteenChild/functions.php on line 578 Code is placed in functions.php. Not sure I am getting this error syntax error message. My function looks correct but it throws out the above error. When I remove this code functions.php works fine. I don't think my code is a problem (or maybe it is?) so I am hoping a second set of eyes or some suggestions would help solve this error. Code __('Footer Menu') ) ); } add_action('init', 'register_my_menus'); ?>
Viewing 3 replies - 1 through 3 (of 3 total) WEN Solutions @wen-solutions 10 months, 2 weeks ago Hello @pcosta88, Your codes look fine and it is working well for me in WordPress 4.4. Please try changing the theme and us the above code in that theme. Thanks! DionDesigns @diondesigns 10 months, 2 weeks ago I'll bet if you get rid of the at the end, the code will work perfectly. 🙂 Here's a cleaned-up version of your code: function register_my_menus() { register_nav_menus(array( 'footer-menu' => __('Footer Menu'), )); } add_action('init', 'register_my_menus'); Pcosta88 @pcosta88 10 months, 2 weeks ago Super weird, I cut out the code that was bothersome, saved the functions.php, then put the code back in, saved it, restarted my XAMPP…and the error message went away. ¯\_(ツ)_/¯ Thanks for all the suggestions! Viewing 3 replies - 1 through 3 (of 3 total) You ma 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 Business Learn more about hiring developers or posting ads with us Magento Questions Tags Users Badges Unanswered Ask Question _ Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top PHP Parse error: syntax error, unexpected T_FUNCTION, expect up vote 1 down vote favorite I get error PHP Parse error: syntax error, unexpected T_FUNCTION, expecting ‘)’ in site.com/app/code/community/EbayEnterprise/Affiliate/Helper/Data.php on line 41 from Data.php 37 public function getAllProgramIds() 38 { 39 $config = Mage::helper(’eems_affiliate/config’); 40 return array_unique(array_filter(array_map( 41 function ($website) use ($config) { 42 return $config->getProgramId($website->getDefaultStore()); 43 }, 44 Mage::app()->getWebsites() 45 ))); 46 } this code for php 5.3 - but I use only php 5.2.17, and can not apdate - please help change this line 41 - that can be work on php 5.2.17 Thank you/ Have a good day)) p.s. sorry for my English I am from Ukraine php-5.2.x.x share|improve this question asked Nov 9 '14 at 0:37 Oleksandr 62 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote First: you don't want to do this. You want to upgrade your PHP. 5.2 is so extremely outdated at this point you're a sitting duck for every script kid out there. The reason this code doesn't work is because PHP 5.2 doesn't support closures. public function getAllProgramIds() { $config = Mage::helper(’eems_affiliate/config’); $websites = Mage::app()->getWebsites(); $ids = array(); foreach($websites as $website) { $ids[] = $config->getProgramId($website->getDefaultStore()); } return array_unique($ids); } I think that does what you want. Upgrade your PHP! share