Parse Error Unexpected T_lnumber Expecting T_variable
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 syntax error, unexpected t_lnumber about Stack Overflow the company Business Learn more about hiring developers or posting ads
Joomla Parse Error: Syntax Error, Unexpected T_lnumber, Expecting T_variable Or '$'
with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack parse error: syntax error, unexpected '2' (t_lnumber) Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' up vote 3 down syntax error unexpected 3 t_lnumber vote favorite I'm getting Syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' This is the code i'm using function wpse44503_filter_content( $content ) { $regex = '#src=("|\')'. '(/images/(19|20)(0-9){2}/(0|1)(0-9)/[^.]+\.(jpg|png|gif|bmp|jpeg))'. '("|\')#'; $replace = 'src="'.get_site_url( $2 ).'"'; $output = preg_replace( $regex, $replace, $content ); return $output; } This is the line where i'm getting that error $replace = 'src="'.get_site_url( $2 ).'"'; Can anyone help me to fix it? Thanks php regex preg-replace syntax-error
Php T_lnumber
share|improve this question asked Mar 5 '12 at 18:02 user1091558 1,52562138 What, exactly, is $2? –Jack Maney Mar 5 '12 at 18:06 1 $2 is an invalid PHP variable name.... "A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores." –Mark Baker Mar 5 '12 at 18:06 Are you trying to pass the second capture group $2 into that function? (Interesting how many people seem to have missed this.) –BoltClock♦ Mar 5 '12 at 18:07 @BoltClock Yes thats right. I'm trying to pass the second capture group into that function. What should i put there instead of $2 ? Thanks –user1091558 Mar 5 '12 at 18:10 What capture group? You haven't done a regex match (in the code that I can see) before the line $replace = 'src="'.get_site_url( $2 ).'"';. –Jack Maney Mar 5 '12 at 18:25 | show 1 more comment 4 Answers 4 active oldest votes up vote 2 down vote accepted What you're trying to do (ie replacing the matched string with the result of a function call) can't be done using preg_replace, you'll need to use preg_replace_callback instead to get a function calle
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies http://stackoverflow.com/questions/9571559/syntax-error-unexpected-t-lnumber-expecting-t-variable-or of this site 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 http://stackoverflow.com/questions/22183063/parse-error-syntax-error-unexpected-t-lnumber-expecting 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 error, unexpected T_LNUMBER, expecting ')' [closed] up vote 0 down vote favorite I'm getting Parse error: syntax error, unexpected T_LNUMBER, expecting ')' This is the code I'm using: function getLevelByXp($xp) { $listlevel=array(0,40,60,100,200,350,550,800,1113,1504,1993,2604,3368,4323,5517,7010,8876,11209,13659,16232,18934,21771,24750,27878,31162,34610,38230,42031,46022,50213,54614,59235,64087,69182,74532,80150,86049,92243,98747,105576,112746,120275,128180,136480,145195,154346,163955,174044,184637,195760,207439,219702,232578,246098,260294,275200,290851,307285,324541,342660,361685,381661,402636,424660,447785,472066,497561,524331,552440,581954,612944,645484,679651,715526,756782,804226,858787,921532,993689,1076670,1172098,1281840,1408043,1553176,1720079,1912017,2132746,2386584,2678498,3014199,3400255,3844219,4354778,4941921,5617135,6393631,7286601,8313517,9494470,2016089205); $j=count($listlevel); for($i=0;$i<$j;$i++){ if($listlevel[$i] > $xp) break; } return $i; } This is the line where i'm getting that error $listlevel=array(0,40,60,100,200,350,550,800,1113,1504,1993,2604,3368,4323,5517,7010,8876,11209,13659,16232,18934,21771,24750,27878,31162,34610,38230,42031,46022,50213,54614,59235,64087,69182,74532,80150,86049,92243,98747,105576,112746,120275,128180,136480,145195,154346,163955,174044,184637,195760,207439,219702,232578,246098,260294,275200,290851,307285,324541,342660,361685,381661,402636,424660,447785,472066,497561,524331,552440,581954,612944,645484,679651,715526,756782,804226,858787,921532,993689,1076670,1172098,1281840,1408043,1553176,1720079,1912017,2132746,2386584,2678498,3014199,3400255,3844219,4354778,4941921,5617135,6393631,7286601,8313517,9494470,2016089205); Edit: Here is m
that make connections all over the world. Join today Download & Extend Drupal Core Distributions Modules Themes Features OverrideIssues Parse error: syntax error, unexpected '0' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' https://www.drupal.org/node/2009084 or '$' in Closed (fixed)Project:Features OverrideVersion:7.x-2.x-devComponent:CodePriority:MajorCategory:Bug reportAssigned:UnassignedReporter:jepSterCreated:May 31, 2013 - 14:13Updated:August 15, 2014 - 14:30 Log in or register to update this issue Jump to:Most recent comment Most recent attachment Hi, I'm getting this error: Parse error: syntax error, unexpected '0' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in MY-FEATURE.features.inc on line 12 I want to override a rule. I have PHP 5.4 installed. I'm syntax error getting this error with the latest beta- and dev-version.Files: CommentFileSizeAuthor #1 3220.png93.83 KBMiff Comments Comment #0.0 jepSter CreditAttribution: jepSter commented May 31, 2013 at 2:14pm Issue summary: View changes Typo Log in or register to post comments Comment #1 Miff CreditAttribution: Miff commented October 31, 2013 at 2:21pm FileSize 3220.png93.83 KB Have experienced same behavior. Log in or register to post comments Comment #1.0 Miff CreditAttribution: Miff commented October syntax error, unexpected 31, 2013 at 2:21pm Issue summary: View changes Typo Log in or register to post comments Comment #2 rob_johnston CreditAttribution: rob_johnston commented March 17, 2014 at 2:46pm Issue summary: View changes I also occasionally get parse errors. In my case, the line number of the error points directly to the problem. I have visibility rules on a panel that are set with a wildcard such as a URL of '*/rcc/*. A change to the feature will generate a comment like: */rcc/*'; /* WAS: '*/rcc-ccr/* The problem is that the comment is not escaped. This can easily be corrected by replacing all occurrences of '*/' with '*\/'. Log in or register to post comments Comment #3 milesw CreditAttribution: milesw commented March 23, 2014 at 7:26am Same problem when trying to export Elysia Cron rules which contain a number of asterisks and slashes. Example that causes a parse error: /** * Implements hook_default_elysia_cron_rules_alter(). */ function myfeature_default_elysia_cron_rules_alter(&$data) { if (isset($data['feeds_cron'])) { $data['feeds_cron']->rule = '*/2 * * * *'; /* WAS: '*/3 * * * *' */ } if (isset($data['job_scheduler_cron'])) { $data['job_scheduler_cron']->rule = '*/2 * * * *'; /* WAS: '*/3 * * * *' */ } } Log in or register to post comments Comment #4 rootwork CreditAttribution: rootwork