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 trial

PHP

All the arrays and data from data.php file appears on browser when "include " is added to catalog.php.

I have problem with array from data.php appears on browser when i add "include " to php tag in catalog file. When I add include ("inc/data.php"); within php tag in catalog.php file and save it then i preview the results, all arrays shows up on the browser!!! , just like below

$catalog[101] = [ "title" => "A Design Patterns: Elements of Reusable Object-Oriented Software", "img" => "img/media/design_patterns.jpg", "genre" => "Tech", "format" => "Paperback", "year" => 1994, "category" => "Books", "authors" => [ "Erich Gamma", "Richard Helm", "Ralph Johnso .... .... to the end of array

So may i know what is the problem and i also using Treehouse workspace and i watched the video many times. Thanks

1 Answer

Simon Coates
Simon Coates
28,694 Points

does data.php start with <?php ?

Thanks Simon, you are so smart. it is working. Unfortunately i didn't add <?php to data file and also the teacher didn't add too