| View previous topic :: View next topic |
| Author |
Message |
dansit
Joined: Tue Jul 27, 2010 5:10 pm Posts: 1 Location: southwest UK
|
Posted: Tue Jul 27, 2010 6:45 pm Post subject: PHP coding academy project 1 |
|
|
Hi i have been going through the project 1 php academy book and have come across and experiencing problems! May be i am making a simple fault.
I have got to page 22 and all work well! Got the right output at the terminal. When i got to page 23 and added the extra code i start to get error's when running the script.
This was the page 23 code i added to the script.
chdir("..");
subdir_scan(".")
This is the complete code and error's.
| Code: | <?php
function chdir("..");
subdir_scan(".");
subdir_scan($dir){
$files = scandir($dir);
foreach($files as $files){
if ($files==".")continue;
if ($files=="..")continue;
print "$dir/$files\n";
if (is_dir("$dir/$files")){
subdir_scan("$dir/$files");
}
}
}
subdir_scan(".")
?> |
Error message.
| Code: | PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '&' or T_VARIABLE in /home/username/php/project1.php on line 3
|
Any help in what i have done wrong would be great! I'm sure it's a simple mistake i've made but i have checked over and over again!
I am a simple newbie forgive me for not spotting the problem.  |
|
| Back to top |
|
 |
Dutch_Master LXF regular
Joined: Tue Mar 27, 2007 2:49 am Posts: 2354
|
Posted: Tue Jul 27, 2010 8:56 pm Post subject: |
|
|
Actually, the solution is part of the error mesage:
| Code: | | PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '&' or T_VARIABLE in /home/username/php/project1.php on line 3 | The clue is in the last part: | Quote: | | expecting '&' or T_VARIABLE in /home/username/php/project1.php on line 3 | Now, look at your code, what's on line 3? | Code: | | function chdir(".."); | The PHP parser says it's invalid syntax. The question you now need to ask yourself is: "why is that invalid?" and go from there  |
|
| Back to top |
|
 |
leke LXF regular

Joined: Mon Oct 22, 2007 6:45 pm Posts: 479 Location: Oulu, Finland
|
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|