This has little to do with PHP or Javascript, it has to do with the pseudo algorithm you start with.

A good programming technique is DRY: Don't Repeat Yourself.

Here's a suggestion:

Create a loop for document.getElementById('canvas-message-line(i)') (1<=i<=9)

In that loop, get document.getElementById('canvas-message-line(i)').value to fill the context.fillText at the current position (starts with 20)and increase the parameter's value by 15: 20, 20+15 (35), 20+15+15 (50),...