Php Syntax Error Unexpected T_variable Expecting 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 company expecting function (t_function) php Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs syntax error, unexpected '$data' (t_variable), expecting function (t_function) Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, syntax error, unexpected '$this' t_variable 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 basic syntax error I
Syntax Error Unexpected Function T_function
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 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--that is, it must be able to be evaluated at compile time and
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 syntax error, unexpected '->' (t_object_operator) Overflow the company Business Learn more about hiring developers or posting ads with us
Class Constructor Php
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community
Php Class Example
of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Unexpected T_VARIABLE, expecting T_FUNCTION fix up vote 2 down vote favorite I am getting this syntax http://stackoverflow.com/questions/6486660/unexpected-t-variable-expecting-t-function error when running my php. Here is the code for a class I am trying to costruct: function makeObject($s) { $secobj = new mySimpleClass($s); return $secobj; } class mySimpleClass { $secret = ""; public function __construct($s) { $this -> secret = $s; } public function getSecret() { return base64_encode(string $secret); } } Anyone see whats wrong? Thanks! php oop share|improve this question edited Nov 16 '14 at 1:47 Ghost 35.4k122545 asked http://stackoverflow.com/questions/26943573/unexpected-t-variable-expecting-t-function-fix Nov 15 '14 at 7:17 Felicia 112 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote You need to set the visibility of $secret private $secret = ""; Then just remove that casting on the base64 and use $this->secret to access the property: return base64_encode($this->secret); So finally: class mySimpleClass { // public $secret = ""; private $secret = ''; public function __construct($s) { $this->secret = $s; } public function getSecret() { return base64_encode($this->secret); } } share|improve this answer edited Nov 15 '14 at 8:14 answered Nov 15 '14 at 7:19 Ghost 35.4k122545 that seemed to work! thanks! –Felicia Nov 15 '14 at 7:22 @Felicia sure, im glad this helped –Ghost Nov 15 '14 at 7:23 so it is supposed to echo mySimpleClass Object ( [secret:mySimpleClass:private] => Honey Pot ) sg9uzxkgug90 but it only echos mySimpleClass Object ( [secret] => Honey Pot ) –Felicia Nov 15 '14 at 7:49 @Felicia you need to echo it from your getter method. echo $obj->getSecret() –Ghost Nov 15 '14 at 7:57 1 Aye good, no need for the $secret to be public at this point. –Cliffordlife Nov 15 '14 at 8:13 | show 2 more comments up vote 0 down vote I
Involved Learn how you can get involved with the project. 3.1 New Features An overview of the new features and improvements in phpBB 3.1 (The new https://www.phpbb.com/community/viewtopic.php?f=46&t=2124700 version of phpBB). The Team Find out who is responsible for all the mayhem. Contact Us Have a question the forums don't answer? Come here. Advertising Information if you want to advertise http://board.phpbuilder.com/showthread.php?10331077-Parse-error-syntax-error-unexpected-T_VARIABLE-expecting-T_OLD_FUNCTION on phpBB.com. Find out more about the project » Downloads Latest Version Download the latest stable release of phpBB Update Packages Automatic Update packages for your phpBB release Language Packs Translate phpBB into syntax error (almost) any language you like Extensions Download extensions to enhance phpBB’s functionality Styles Your forums need a new look? Browse our Styles DB Official Tools Official tools by the phpBB team to assist you with your board Customise Customisation Database Our customisation database contains just about everything you might need to customise your phpBB board to your liking. In it you will find Extensions (for 3.1.x), syntax error, unexpected MODs (for 3.0.x), Styles, Language Packs, BBCodes, as well as various tools. Extensions (3.1.x) Guides on how to use them and how to create your own. Extensions DB Download or submit extensions to our extensions database. Modifications (3.0.x) Guides on how to use them and how to create your own. Modifications DB Download or submit modifications to our MODs database. Styles Guides on how to use them and to create your own styles. Styles DB Download or submit styles to our styles database. More resources on customising your board » Support Documentation Installation guide and the complete documentation. Knowledge Base Team and user submitted articles covering support areas. Flash Tutorials View Flash Tutorials that help you with the use of phpBB. phpBB Support The Support related areas in our community forums. IRC Support Old school? Visit the IRC support channel on freenode. International Support Find a 3rd party support site in your first language. More information on support » Development Area51 phpBB Development All Development Discussion takes place at Area51. Bug tracker, development wiki, continuous integration and other development tools are located here. Find out how to get involved in phpBB development. phpBB Bug T
T_OLD_FUNCTION If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 5 of 5 Thread: Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 10-19-2006,07:25 PM #1 Twysted View Profile View Forum Posts Member Join Date Sep 2006 Posts 28 Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION i keep running into this and been working on it for 2 months and still can't figure it out Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/under/public_html/kp/includes/inc-setup.php on line 16 PHP Code:
//include($incloc."includes/inc-config.php");
classmysql{
functionconnect()
{
//global$DB_INFO;
define('DB_NAME','under_rebels');
$connect=mysql_connect(