vForums Support Banner


Visit Base Classics - Gaming Chairs

 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: Php class error - View Topic
Topic Rating: *****
Printable View
Dylan
Junior Member
**

[Avatar]

Posts: 136
Status: Offline
Gender: Male
Joined:  
Reputation: 0%  


pmwwwmsnaimxfire
Php class error (29th Mar 08 at 7:06pm UTC)
I have an error
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?


Image
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Php class error (29th Mar 08 at 7:14pm UTC)
$this->cache_dir = $cache_dir;
$this->$cache_dir = $cache_dir;

isn't it? {Unsure}
Dylan
Junior Member
**

[Avatar]

Posts: 136
Status: Offline
Gender: Male
Joined:  
Reputation: 0%  


pmwwwmsnaimxfire
Re: Php class error (29th Mar 08 at 7:16pm UTC)
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 $


Image
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Php class error (29th Mar 08 at 9:05pm UTC)
Line 4 you put a ( at the end, instead of a {
Dylan
Junior Member
**

[Avatar]

Posts: 136
Status: Offline
Gender: Male
Joined:  
Reputation: 0%  


pmwwwmsnaimxfire
Re: Php class error (30th Mar 08 at 4:40pm UTC)
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


Image
 Printable View

All times are GMT+0 :: The current time is 8:46am
Page generated in 0.1503 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums