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

What PHP version will I be running?

I know this probably sounds like a silly question but what PHP version would I be running If I am just writing PHP commands within sublime text?

Does the browser assume I am using the latest version?

Little bit confused regarding PHP versions. If I were to upload these .php files to a server, what version would it be running?

3 Answers

Kevin Korte
Kevin Korte
28,149 Points

I know Stanley gave you a good answer, so I'll just address your questions specifically.

  • what PHP version would I be running If I am just writing PHP commands within sublime text?
  • At this point is version independent, unless you're using parts of PHP that were only available in certain versions of it, you'll want to be aware of this. You should catch these errors when you go to a staging server though, as it'll become obvious you have an error

  • Does the browser assume I am using the latest version?

  • The browser has nothing to do with PHP. It doesn't care. The browser only deals with the HTML, CSS, and JS of your website. When the user makes a request, the browser sends that request to your server, where the server would process the request, parse any PHP you have as part of that request, and return to the browser only HTML, CSS, and JS

  • If I were to upload these .php files to a server, what version would it be running?

  • Depends on what version of PHP is installed on the server. Most hosting companies are going to do this for you, will not allow you access to it, and will update versions pretty quickly after a new version is released. Some situations like a VPS (virtual private server) or a dedicated server will allow you access to install and maintain whatever version of PHP you want, along with all of the other software pieces need for a server.

Stanley Thijssen
Stanley Thijssen
22,831 Points

Hey Max,

You can easily check your php version by one of the following 2 commands in php:

<?php
phpinfo();
?>

or

<?php
echo phpversion();
?>

the phpinfo(); gives more info about the php your running on the server you using, and the phpversion(); just returns the version of your php on the current server you using.

The version can differ from server to server so its always a good thing to check what phpversion your using by one of those 2 commands.

Makes sense, thanks a lot!