Error Unexpected Expecting T_function In
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Parse Error: Syntax Error, Unexpected '?>', Expecting Function (t_function) In
policies of this site About Us Learn more about Stack Overflow the unexpected end of file, expecting function (t_function) company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Syntax Error, Unexpected '$this' (t_variable), Expecting Function (t_function)
Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only syntax error, unexpected '$data' (t_variable), expecting function (t_function) takes a minute: Sign up Parse error: “syntax error, unexpected ';', expecting T_FUNCTION” up vote 2 down vote favorite Sample Code: Config.php: class Config { public $serverIP = "1.1.1.10"; } DB.php: require_once "/home/mysite/PHP/Config.php"; class DB extends Config { //DB related functions here.. } research.php: require_once "/home/mysite/PHP/DB.php"; class research extends DB { // Using DB functions to retrieve information from the research parse error: syntax error, unexpected 'public' (t_public) tables. } On executing the research.php file, I am getting an error message saying: "Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/mysite/PHP/research.php on line 1". I have checked every possibility that may cause this error. But I couldn't fix it. I have checked few possibilities such as require_once("filepath"); missing braces, etc... php share|improve this question edited Dec 7 '11 at 8:19 mac 22.3k1288104 asked Dec 7 '11 at 6:12 Sougrakpam 43129 add a comment| 4 Answers 4 active oldest votes up vote 0 down vote accepted This is on line 1, which you didn't post Be sure you have space between
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
Syntax Error, Unexpected '->' (t_object_operator)
the company Business Learn more about hiring developers or posting ads with us Stack parse error syntax error unexpected t_variable Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of
Php Constructor
4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up unexpected T_VARIABLE, expecting T_FUNCTION up vote 11 down vote favorite 3 I am expecting this to be a http://stackoverflow.com/questions/8411133/parse-error-syntax-error-unexpected-expecting-t-function basic syntax error I overlooked, but I can't figure it out. In a PHP script, I keep getting the following error. Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in [path]/scripts/users/database_connection.php on line 4 This occurs when my script to connect to the database is called with an include_once(). I stripped my script down to the most basic code (leaving in what is required by other code), and it still is calling http://stackoverflow.com/questions/6486660/unexpected-t-variable-expecting-t-function this error. I have struggled with this for a while, and just wondered if anyone else could spot somewhere I went wrong. php sqlite syntax-error share|improve this question asked Jun 26 '11 at 20:50 Ryan Leonard 5241525 add a comment| 4 Answers 4 active oldest votes up vote 14 down vote accepted You can not put $connection = sqlite_open("[path]/data/users.sqlite", 0666); outside the class construction. You have to put that line inside a function or the constructor but you can not place it where you have now. share|improve this answer answered Jun 26 '11 at 20:53 Sabeen Malik 9,19821940 Thank you, first time I tried to use OOP. –Ryan Leonard Jun 26 '11 at 20:57 @Rhino , its aright. @Lekensteyn has done a wonderful job and shows you how you should ideally do it. –Sabeen Malik Jun 26 '11 at 20:58 add a comment| up vote 13 down vote You cannot use function calls in a class construction, you should initialize that value in the constructor function. From the PHP Manual on class properties: This declaration may include an initialization, but this initialization must be a constant value--th
‘;', expecting T_FUNCTION By admin | July 19, 2008 If you've ever been stumped by "Parse error: syntax error, unexpected ‘;', expecting T_FUNCTION", you will know that this is a very difficult bug to track. Fortunately, we have found the error for you. This http://www.compdigitec.com/labs/2008/07/19/stopping-syntax-error-expecting-t_function/ error message is very misleading, because your actual problem is that you have an extra semi-colon at the end of your functions, like the one below (see line 12): a = 'Hello World!'; }; # <-- That one }; ?> Now, the above code looks good, but when you try to run it it PHP spits out the syntax error following parse error: Parse error: syntax error, unexpected ‘;', expecting T_FUNCTION in *.php on line * So, to fix it, simply remove the offending semi-colon at the end of your functions. Hope this helped anyone who got stuck with this misleading PHP error. If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles! Topics: PHP | 20 Comments »
20 syntax error, unexpected Responses to "Stopping syntax error, unexpected ‘;', expecting T_FUNCTION" egodi Says: August 27th, 2009 at 1:48 pm mine is PHP Parse error: syntax error, unexpected $end, expecting T_FUNCTION in C:\\\test\file.php on line 86 Gregor Says: September 26th, 2009 at 4:15 am Parse error: syntax error, unexpected ‘;', expecting T_FUNCTION on lin 519. The line 519 is just ?> what can I do? admin Says: September 27th, 2009 at 3:48 pm @Gregor: Did you by accident put in an extra semi-colon somewhere in your code before the "?>"? Gregor Says: September 28th, 2009 at 5:22 am I checked the whole php file, no ; before ?>. Is it possible to send you the (searchajax).php file? This are some of the lines of the code: ?> (<- line 519) Asdf Says: November 11th, 2009 at 2:01 pm Someone said "Parse error: syntax error, unexpected ‘;’, expecting T_FUNCTION on lin 519. The line 519 is just ?>" The same error to me. It was a } missing at the end, just before ?>. It was something like.. It was a deletion error. aeou Says: December 23rd, 2009 at 5:44 pm the following snippet will output the same message (only when inside a class method, not in or out of a procedural function) class Foo { public function foo() { if ($a) { echo ‘foo'; if ($b) { echo ‘