Parse Error Syntax 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 about Stack Overflow the company Business Learn joomla parse error: syntax error, unexpected t_lnumber, expecting t_variable or '$' more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags parse error: syntax error, unexpected '2' (t_lnumber) Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you,
Syntax Error Unexpected 3 T_lnumber
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 vote favorite I'm getting Syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' This is
Php T_lnumber
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 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 called for every match. A short example of preg_replace_callback; $get_site_url = // Returns replacement function($row) { return '!'.$row[1].'!'; // row[1] is first "backref" }; $str = 'olle'; $regex = '/(ll)/'; // String to match $output = preg_replace_callback( // Match, calling get_site_url for replacement $regex, $get_site
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and http://stackoverflow.com/questions/9571559/syntax-error-unexpected-t-lnumber-expecting-t-variable-or policies 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 http://stackoverflow.com/questions/22183063/parse-error-syntax-error-unexpected-t-lnumber-expecting 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 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,6129
that make connections all over the world. Join today Download & Extend Drupal Core Distributions Modules Themes Features https://www.drupal.org/node/2009084 OverrideIssues Parse error: syntax error, unexpected '0' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in Closed (fixed)Project:Features OverrideVersion:7.x-2.x-devComponent:CodePriority:MajorCategory:Bug reportAssigned:UnassignedReporter:jepSterCreated:May 31, 2013 - 14:13Updated:August https://github.com/sebastianbergmann/phpunit-mock-objects/issues/62 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 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 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 syntax error unexpected 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 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 regist
Sign in Pricing Blog Support Search GitHub This repository Watch 16 Star 150 Fork 121 sebastianbergmann/phpunit-mock-objects Code Issues 16 Pull requests 5 Projects 0 Pulse Graphs New issue Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING in C:\php\PEAR\PHPUnit\Framework\MockObject\Generator.php(184) : eval()'d code on line 11 #62 Closed CloCkWeRX opened this Issue Jun 21, 2011 · 0 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 2 participants CloCkWeRX commented Jun 21, 2011 Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING in C:\php\PEAR\PHPUnit\Framework\MockObject\Generator.php(184) : eval()'d code on line 11 With PHPUnit 3.5 / PHPUnit MockObject 1.0.9; I see fatal errors with the below test case: getMock('ExampleMatcher', array('0')); $matcher->expects($this->once()) ->method('match'); } } // A simple mock class class ExampleMatcher { public function __construct($rp_id) { $this->rp_id = $rp_id; } public function match(CLS_address $address, CLS_address_rp $rp) { $rp->setRPID($this->rp_id); return $rp; } } Of course; this is just me being half asleep and passing in an invalid method name to the mock framework (I thought I was passing in arguments; doh). Unfortunately it results in a fatal error on code I can't see unless I get into the depths of the framework. An exception would be handy. From http://www.php.net/manual/en/functions.user-defined.php Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*. edorian added a commit to edorian/phpunit-mock-objects that referenced this issue Jun 21, 2011 edorian #62 df3ef93 sebastianbergmann pushed a commit that closed this