Saturday, August 1, 2009

The Difference Between PHP and JavaScript by Bob Ryan

PHP and JavaScript are both scripting languages commonly used in web development. The big difference between the two is where they are most often employed. JavaScript is the primary language for execution by the client side, i.e. the browser. PHP, a recursive acronym for PHP: Hypertext Processor, is typically implemented on the server side. As such, it is insulated from the variances in browsers and desktops that has handicapped JavaScript.

Server-side scripts for web pages are also coded in languages like Perl or C, but PHP has gained popularity in the role. One advantage PHP enjoys over alternatives is that it was created for scripting web pages, and thus has features for performing a number of typical web design functions included. Another plus is that PHP was designed to coexist with HTML; the acronym originally meant Personal Home Pages. When used to output text, PHP is embedded within the HTML code, whereas in the case of Perl, the opposite situation usually exists -- the HTML would be produced by Perl code. The net effect is that the PHP and HTML solution is cleaner and more readable.

PHP does well in terms of execution time performance. PHP developers have made optimization a priority. As with database improvements, performance gains made on server-side scripts greatly enhance the efficiency of a web site. Unlike languages that compile code in advance and keep binary executables for processing requests, PHP compiles scripts when they are used. To save the cost of having to compile the same code for every request, a code cache is used to reduce the compilation required.

Although either PHP or JavaScript could be used on the opposite side of the web client-server relationship, neither is truly general purpose. Both are best suited to the respective niche where they evolved.

0 comments:

Post a Comment

  © Blogger template The Business Templates by Ourblogtemplates.com 2008

Back to TOP