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 PHP Basics (Retired) PHP Conditionals & Loops For Loops

Darrell Conklin
Darrell Conklin
21,988 Points

Undefined Variable

Let me start by saying I really just don't like workspaces and prefer VS. So, instead of using WS I run WAMP and edit the PHP in VS. When I created the for loop like you showed in the video and refreshed the page I got error notices about undefined variables. So I went to the top of the page and defined the variable $counter = 0; and the notice went away but I didn't have any issues with this in WS. Do you have your server set up to be more forgiving or is my software being anal for no good reason. Just looking for some clarification.

1 Answer

Darrell,

I use wamp as well and like it. Your problem lies in your php.ini file for errors. You can skimmed down to the errors and warnings section and set it up to only display fatal errors and not notices or warnings. Having a warning isn't a bad thing most of the time so most people surpress notices and warnings in production and leave it on in the development environment for debugging. Take a look at your php.ini file and once you tell the server to ignore warnings you'll be fine. I think workplaces have warnings surpressed by default. Just make sure that any changes you do in your php.ini file you restart your server for the changes to take effect. Hope this helps.

Cheers!

Darrell Conklin
Darrell Conklin
21,988 Points

Thanks a bunch no more error messages :D