Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,731 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,228 people online right now. Registration is fast and FREE... Join Now!




php vs javascript

 
Reply to this topicStart new topic

php vs javascript

R Power
post 13 Oct, 2008 - 07:19 AM
Post #1


New D.I.C Head

*
Joined: 9 Oct, 2008
Posts: 4


My Contributions


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.
User is offlineProfile CardPM

Go to the top of the page

Nykc
post 13 Oct, 2008 - 07:25 AM
Post #2


sudo rm -R /

Group Icon
Joined: 14 Sep, 2007
Posts: 3,971



Thanked 12 times

Dream Kudos: 275
My Contributions


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.
User is online!Profile CardPM

Go to the top of the page

William_Wilson
post 13 Oct, 2008 - 07:41 AM
Post #3


lost in compilation

Group Icon
Joined: 23 Dec, 2005
Posts: 3,951



Thanked 13 times

Dream Kudos: 3275

Expert In: Java, C, Javascript

My Contributions


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.
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 10:37AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month