2 Replies - 5181 Views - Last Post: 13 October 2008 - 08:41 AM

#1 R Power  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-October 08

php vs javascript

Post icon  Posted 13 October 2008 - 08:19 AM

Hi freinds
What's diff. between php and js. I know that php is for server side scripting and handles user data etc. and js is client side scripting and interacts with user but all features of js are in php i.e what is the need of js then , php alone can do everything. I mean what is the need to learn js then. Is this because that for user interactions php will take more time or what??????
Secondly, how to execute a php script in html page. Like to execute js we do
<script type="text/javascript" src="/xxx.js">
Similarly to execute xxx.php what to do..............
Or I have to save the html page as .php and then include the xxx.php file using include function.

Is This A Good Question/Topic? 0
  • +

#3 Nykc  Icon User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 737
  • View blog
  • Posts: 8,648
  • Joined: 14-September 07

Re: php vs javascript

Posted 13 October 2008 - 08:25 AM

Javascript is good to use when you don't need to interact with the server. To display a greeting message or a date on a webpage does not need to go to the server therefore it would be more efficient to use Javascript.

Error checking before sending off to the server can be performed as well in Javascript
Forms are better suited to work with Javascript, pop-ups, Javascript is lightweight portable and you don't need a .php extension to communicate.

I like to use both php and Javascript in my apps to reduce server load. If it can be done in Javascript and I do not need to query the server - it is done in JS.

There are other great examples, but maybe this will help you understand the differences. It honestly boils down to personal preference and the amount of load you want the server to handle which can also slow down response time.
Was This Post Helpful? 1

#4 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 207
  • View blog
  • Posts: 4,812
  • Joined: 23-December 05

Re: php vs javascript

Posted 13 October 2008 - 08:41 AM

I consider javascript to be a convenience language. You can do all kinds of interesting things with menus and routing of pages with it, but it is all for show, server side languages like php are the bulk of your sites.

Offering client side error checking is nice, it allows a user to correct issues before the data is sent, which can save a lot of time especially on a slow connection. Of course these values will need to be checked server side as well, but hopefully you see the reason for client side too.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1