PHP & More

A technical blog about programming in PHP and about technology in general: programming, workarounds and troubleshooting

How do you declare a static variable in a JavaScript function? Not with the word “static“. In JavaScript “function” is a variable type similar to “object“. The difference is that the reference to a function inside itself is not this but arguments.callee. An example of using arguments.callee is the following function that returns itself: function …

Continue reading

Browsers supporting HTML5 allow you to draw on the browser’s screen without preparing an image file before. Drawing on a canvas is done using the wonderful Javascript language. If you want to draw a 2-dimensional image on canvas element ‘cnv’, get the drawing context using: var ctx = cnv.getContext(“2d”) And use that context to draw …

Continue reading