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 mouse-overs, whereas PHP cannot. So while PHP cannot do certain things that JavaScript can, PHP can be used to make JavaScript.

Sending JavaScript Data to PHP

As the example in this section shows, sending data from PHP to JavaScript ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide 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.