Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialannapoff
13,552 PointsError in the treehouse code!! I think this is a bug!
I keep getting this error:
Parse error: syntax error, unexpected '$title' (T_VARIABLE) in /home/treehouse/workspace/index.php on line 4
This is a line of code that came preloaded on the workspaces.
I've included all of the files worked with so far index.php
<?php
require_once"src/config.php"
//the line below is in question
$title = "My Website";
require 'views/header.php';
require 'views/footer.php';
config.php
<?php
function autoloader($class_name) {
foreach(glob(__DIR__ . '*/', GLOB_ONLYDIR) as $dir) {
if (file_exists("dir/" . $class_name . '.php')) {
require_once "dir/" . $class_name . '.php':
break;
}
}
}
spl_autoload_register('autoloader');
Collection.php
<?php
class Collection {
}
2 Answers
Gregor Medvesek
16,461 Pointsline 3 on index.php is missing a semicolon at the end
require_once "src/config.php";
Glenré Charl Labuschagné
23,204 PointsHi annapoff,
In your src/config.php file your missing a $ before "dir/" variable…
if (file_exists("$dir/" . $class_name . '.php')) {
require_once "$dir/" . $class_name . '.php';
break;
}
Hope it helps