Error Unexpected T_string 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 parse error: syntax error, unexpected t_string, expecting t_variable or '$' company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions parse error: syntax error, unexpected '(', expecting variable (t_variable) or '$' Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million parse error, expecting variable (t_variable)"' programmers, just like you, helping each other. Join them; it only takes a minute: Sign up PHP Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE [closed] up vote 2 down vote favorite 1 I have this error syntax error, unexpected '__construct' (t_string), expecting variable (t_variable) on line 28 which is below. private loadText() { $this->text = $wiki->getpage($this->page);} The surrounding code can be seen below public function parse() { $this->parser = new parser($page,$this->getText()); $this->parser->parse();} // private functions private loadText() { $this->text = $wiki->getpage($this->page);} private parseNamespace(){... I have can't see the problem and my only guess is that it is something to do with $this-> php share|improve this question asked Jan 23 '13 at 22:41 mr.user1065741 1972315 closed as too
T_constant_encapsed_string
localized by mario, AD7six, Jocelyn, Neolisk, Ram kiran Jan 24 '13 at 3:01 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question. 2 Everytime I read "PHP Parse error" in the title of a SO-question I think to myself: "Why don't you use an IDE?" So, why don't you use and IDE, that marks syntax error right in the editor pane? –KingCrunch Jan 23 '13 at 22:43 what PHP IDE would you suggest? –mr.user1065741 Jan 23 '13 at 22:45 Any ;) It's completely up to you. I don't know a PHP-IDE, that is not able to find syntax errors. So there are (probably incomplete) Eclipse/PDT, Netbeans, PhpStorm (my personal favorite) and many others I don't remember yet. –KingCrunch Jan 23 '13 at 22:49 Aptana Studio 3 is awesome –William Oct 6 '15 at 14:18 add a comment| 1 Answer 1 active oldest votes up vote 15 down vote accepted Your forgot
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
Php Function
Learn more about Stack Overflow the company Business Learn more about hiring developers laravel 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 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up unexpected T_STRING, expecting T_VARIABLE up vote 0 down http://stackoverflow.com/questions/14490732/php-parse-error-syntax-error-unexpected-t-string-expecting-t-variable vote favorite I'm new to php and I am trying to create a member system for my website. I seem to get an error on line 9 ("public function__construct(){") saying 'syntax error, unexpected T_STRING, expecting T_VARIABLE'. I would appreciate any help on why I am getting this error. Thanks. My code: db = new connection (); $this->db = http://stackoverflow.com/questions/20291183/unexpected-t-string-expecting-t-variable $this->db->dbConnect(); } public function Login($name, $pass){ if (!empty($name) && !empty($pass) ) { $st = $this->db->prepare("select * from users where name=? and pass=?"); $st->bindParam(1, $name); $st->bindParam(2, $pass); $st->execute(); if ($st->rowCount() == 1) { echo "user verified access granted"; }else{ echo "Incorrect username or password"; } }else{ echo "Please enter username and password"; } } } ?> php share|improve this question asked Nov 29 '13 at 17:54 user3049921 1915 3 Missing a space after function in public function__construct(){ –j08691 Nov 29 '13 at 17:55 thank you very much, it worked! –user3049921 Nov 29 '13 at 17:58 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted I see two possible errors : public function __construct() ... and next one is : replace 1 , 2 while binding with '1' and '2' share|improve this answer answered Nov 29 '13 at 18:01 Prashant Ghimire 2,3481026 add a comment| up vote 0 down vote try function _construct() instead of function_construct() share|improve this answer answered Nov 29 '13 at 17:59 andresmijares25 444721 Note: you should use 2 underscores –Patrick Kostjens Nov 29 '13 at 18:16 add a comment| Your Answer draft saved draft discarded S
PHP Forum View Course 508 points Submitted by bobfleming almost 3 years ago 5/10 Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE on line 16 In both https://www.codecademy.com/en/forum_questions/52bb7913548c35e324005ed6 5/10 and 6/10 I ge the following parsing error: Parse error: syntax https://answers.yahoo.com/question/index?qid=20130327141323AAqMxSc error, unexpected TSTRING, expecting TVARIABLE on line 16 This is line 16: public function_construct($firstname, $lastname, $age) { I can't find anything wrong. I know what strings and variables are, but what does the prefix "T" indicate in the error message? Despite the message, the m\code passes to go on to syntax error, the next exercise, but there is no output. I am using the code from 1/10 as a guide, along with instructions and hints, and everything in my code looks right! $frustration = "unresolved errors!"; My complete code follows:
firstname = $firstname; $this->lastname = $lastname; $this->age = $age; public function $greet() { return "Hello, my name is " . $this->firstname . " " . $this->lastname . '. nice to meet you! :-)"; } } $teacher = new Person ("boring", "12345"' 12345); $student = new Person ("Bob", "Fleming", 77); echo greet($teacher); echo greet($student); echo $student->age; ?>
0 votes permalink Something I forgot to point out in my question above -- I see nothing in my constructor that looks anything like a string (enclosed in ' ' or " ")!!! One more thing is that since I posted my question I worked through the remaining exercises up through 10/10, and I got the same parsing error on the constructor in all of them, and none of them went, but all of them gave the "Way to go! and the green "Start next lesson" button. Go figure! This could be a bug in the parsing code. 508 points Submitted by bobfleming almost 3 years ago 0 votes permalink Hi Bob, you need to get a space iAnswers Home All Categories Arts & Humanities Beauty & Style Business & Finance Cars & Transportation Computers & Internet Consumer Electronics Dining Out Education & Reference Entertainment & Music Environment Family & Relationships Food & Drink Games & Recreation Health Home & Garden Local Businesses News & Events Pets Politics & Government Pregnancy & Parenting Science & Mathematics Social Science Society & Culture Sports Travel Yahoo Products International Argentina Australia Brazil Canada France Germany India Indonesia Italy Malaysia Mexico New Zealand Philippines Quebec Singapore Taiwan Hong Kong Spain Thailand UK & Ireland Vietnam Espanol About About Answers Community Guidelines Leaderboard Knowledge Partners Points & Levels Blog Safety Tips Computers & Internet Programming & Design Next PHP: syntax error, unexpected T_STRING, expecting T_VARIABLE? 1. _name = $name; 7. } 8. public function writeName() { 9. echo 'My name is ', $this->_name, '.
'; 10. } 11.... show more 1. _name = $name; 7. } 8. public function writeName() { 9. echo 'My name is ', $this->_name, '. '; 10. } 11. } 12. ?> 1. writeName(); 5. ?> The error I get: Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ToyRobot.php on line 5 Don't know what to do. The version of PHP I'm using is 5.3.23. Please, help. Follow 2 answers 2 Report Abuse Are you sure you want to delete this answer? Yes No Sorry, something has gone wrong. Trending Now Minnie Driver Kylie Jenner Conan O'Brien Tanya Tucker Boko Haram 2016 Crossovers Chaka Khan Oil prices Psoriatic Arthritis Symptoms Car Batteries Answers Best Answer: this is because you are using a string on a function that needs a variable(this happens to me a lot ) Source(s): ? · 4 years ago 0 Thumbs up 0 Thumbs down Comment Add a comment Submit · just now Asker's rating Report Abuse use public __function construct() on line 5 instead of public __construct alone