Wednesday 15 August 2012

php - Error when using file_get_contents for class property -


I get an error saying something unexpected '(' when trying to do this in a class:

  private $ doglist = file_get_contents ('dogdropdown.html');  

Is not permission for any reason? I try to use a function like this Key:

  public function getDogList () {$ list = file_get_contents ('dogdropdown.html'); return $ list;}  

no work I wrote it in the right place.

You can only specify the original scalar values ​​or the null for the variable that should be referred to. If the property needs to catch the result of some operation, then you can specify it You can make it stable or neither can you assign to a constructor or a method of class.

To do what you are trying to do, you need to:

< Pre> < Code> class MyClass {private $ dog list; Function __ conversion () {$ this- & gt; Doglist = file_get_contents ('dogdropdown.html'); }}

No comments:

Post a Comment