timothyarden Posted November 9, 2012 Share Posted November 9, 2012 Hi Guys, I am getting this error, Parse error: syntax error, unexpected T_VAR in D:\Program Files\XAMPP\htdocs\agg\edit_home_content.php on line 31 (Line 31 is the 2nd line of code) For this code (It is inside a class) public function edit_home_content(){ var $content_file = fopen('home_content.xml','r'); var $previous_content = fgetc(content_file); var $values = $values; var $values .= $previous_content; // add the above to the bottom of the new code // then write below fclose($content_file); var $content_file = fopen('home_content.xml','r+'); fwrite(content_file,$this -> values); fclose(content_file); } Any Suggestions? Thanks in advance Timothy Link to comment https://forums.phpfreaks.com/topic/270520-php-problems-should-be-quick/ Share on other sites More sharing options...
timothyarden Posted November 9, 2012 Author Share Posted November 9, 2012 Sorry about the tab in - it wasnt supposed to look like that. Still readable though. Link to comment https://forums.phpfreaks.com/topic/270520-php-problems-should-be-quick/#findComment-1391387 Share on other sites More sharing options...
PFMaBiSmAd Posted November 9, 2012 Share Posted November 9, 2012 When you define class properties, you can only assign fixed/constant values as part of the declaration. You cannot assign variables, the result of functions... when you define the class properties. Also, the var keyword is php4 syntax. You should be using public, private, or protected Link to comment https://forums.phpfreaks.com/topic/270520-php-problems-should-be-quick/#findComment-1391390 Share on other sites More sharing options...
timothyarden Posted November 9, 2012 Author Share Posted November 9, 2012 sorry i dont understand my code goes like this class name { function name { variables and actions here } } Link to comment https://forums.phpfreaks.com/topic/270520-php-problems-should-be-quick/#findComment-1391397 Share on other sites More sharing options...
PFMaBiSmAd Posted November 9, 2012 Share Posted November 9, 2012 LOL, that's a class method. You don't use the var keyword at all when assigning values to variables within class methods. Link to comment https://forums.phpfreaks.com/topic/270520-php-problems-should-be-quick/#findComment-1391400 Share on other sites More sharing options...
timothyarden Posted November 9, 2012 Author Share Posted November 9, 2012 Okay, thanks - so that should be my problem? Link to comment https://forums.phpfreaks.com/topic/270520-php-problems-should-be-quick/#findComment-1391401 Share on other sites More sharing options...
Andy123 Posted November 9, 2012 Share Posted November 9, 2012 Okay, thanks - so that should be my problem? Try removing the var keywords and you shall find out. Based on your error message and the fact that the rest of the line is correct, then the answer would be yes. Link to comment https://forums.phpfreaks.com/topic/270520-php-problems-should-be-quick/#findComment-1391404 Share on other sites More sharing options...
timothyarden Posted November 11, 2012 Author Share Posted November 11, 2012 Okay, Thanks heaps for your help guys! Timothy Link to comment https://forums.phpfreaks.com/topic/270520-php-problems-should-be-quick/#findComment-1391641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.