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

General Discussion

which one is better javascript or php ?

Hey i want to know which method will be more suitable to validate a form php or javascript

4 Answers

Nicholas Grenwalt
Nicholas Grenwalt
46,626 Points

They are both awesome languages to learn. In my opinion, JavaScript is more versatile though being that it has libraries that can run on both client (ex. browser) and server side. PHP needs server implementation in order to run constraining its uses. If you decide to go the PHP route though it couples with Content Management Services (CMS) like WordPress very well so that you can make some pretty awesome customization for your sites/apps. Hope that helps clear some things up. Good luck on whichever language you decide.

Hey Nicholas , i want to validate a form which i can do with both javascript and php ,i only want to know which one suitable to validate a form...

I would not even compare them...php and javascript are two really different things. JavaScript is a script language (since it "scripts" in another application (in this case the browser)) that has unique support on every OS...since it gets executed by a browser. PHP is a programming language (application runs on a server) that is able to get compiled (for expample you can even compile php from your terminal) and you also can debug your php code (for example with the tool xdebug).

Yes of course you can do similar things with this languages...but they do it in complete different ways. Just lets talk about speed...node.js is really hyped at the moment (yes it is good) but node.js is fighting with speed problems since the beginning).

I have not the time to explain everything now SO I recommend to read the first post of this Stackoverflow thread...the user explains the differences VERY GOOD: http://stackoverflow.com/questions/6369313/difference-between-javascript-and-php

jason chan
jason chan
31,009 Points

Your going to have to learn both. Javascript is de facto frontend language for the dom. Php is backend. I say use them to solve problems where apt.