PHP and JavaScript

Despite its limitations and cross-browser compliance issues, JavaScript is still a very popular and useful technology in today’s Web pages. Unfortunately, many new PHP programmers have difficulty grasping how PHP and JavaScript interact and differ.

The most significant difference between the two languages is that JavaScript is client-side (meaning it runs in the Web browser) and PHP is server-side. Therefore, JavaScript can detect the size of the browser in pixels, create pop-up windows, and make image mouseovers, whereas PHP cannot.

But while PHP cannot do certain things that JavaScript can, PHP can be used to create or work with JavaScript (just as PHP can create HTML). In this example, PHP will list all the images uploaded ...

Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.