vForums Support > Programming & Coding :: Programming Discussion :: > Php class error

Php class error - Posted By Dylan (dylan) on 29th Mar 08 at 7:06pm
Code:
 
  1. <?php
  2. class settings {
  3. var $cache_dir;
  4.     function __construct($cache_dir = "C:\xampp\htdocs\site2\cache") (
  5.     $this->cache_dir = $cache_dir;
  6.     }
  7.  
  8. }
  9. ?>
 


Theres my class heres the error i'm getting

Quote:
Parse error: syntax error, unexpected '(', expecting ';' or '{' in C:\xampp\htdocs\site2\inc\settings.php on line 5


any ideas?

Re: Php class error - Posted By Michael (wrighty) on 29th Mar 08 at 7:14pm
$this->cache_dir = $cache_dir;
$this->$cache_dir = $cache_dir;

isn't it? {Unsure}

Re: Php class error - Posted By Dylan (dylan) on 29th Mar 08 at 7:16pm
I don't beleive so when your updating a variable in a class.

it's not, when calling a variable inside a class you don't need to include the $

Re: Php class error - Posted By Michael (wrighty) on 29th Mar 08 at 9:05pm
Line 4 you put a ( at the end, instead of a {

Re: Php class error - Posted By Dylan (dylan) on 30th Mar 08 at 4:40pm
Ok thanks Wrigthy {Smile}

New problem when I eche cache_dir this is what it returns?
C mpp\htdocs\board2\cachesupport

when it should be

C:\xampp\htdocs\board2\cache

so the \is cancling out the x and the a but i dno't know whyt?


i just added a \ before the \xa