Jump to content

Php Problems - Should Be Quick


timothyarden

Recommended Posts

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
Share on other sites

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
Share on other sites

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.

Edited by Andy123
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.