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 trialmarvelousperson206
9,199 PointsCan't preview PHP?
The code in this video previews fine through workspace but when I put the same code through Sublime Text the preview shows up blank? Why is this?
2 Answers
Marcus Parsons
15,719 PointsHey Russell,
Since PHP is a server side language, it has to be ran from a server. When you're running the PHP code via Workspaces, it is running that PHP code through the server. When you're editing PHP and trying to preview it on your local machine, you need to use something like an Apache web server, because otherwise, the browser doesn't know how to handle the data so it generally will just output the raw PHP data from the page.
If you use Windows, you can install PHP for IIS: http://php.iis.net/ <-- that link has a wealth of information on using PHP with IIS. If you're using a Mac, you can install MAMP (which also works with Windows). If you're using Linux, I'd have to recommend XAMPP (which I personally use and love and will work on Windows and Mac OS X, as well).
marvelousperson206
9,199 PointsYeah I installed it but I have no idea what I'm doing :p I think It installed the SQL server but I may need to learn more about it first
Marcus Parsons
15,719 PointsHey, at least you got it set up! You should have a directory where you need to store your php files so that the local server can access them. I have no idea what that would be, but then again, Google is your good friend on this! :)
marvelousperson206
9,199 Pointsmarvelousperson206
9,199 PointsOh yeah that makes sense! Thanks. Might try out IIS
Marcus Parsons
15,719 PointsMarcus Parsons
15,719 PointsYou're welcome, Russell. If you can't figure out how to make PHP for IIS work, try out XAMPP. It is the easiest to set up and use Apache server I've used, and it works across multiple platforms.