Unfortunatley, from language design perspective, both PHP and JavaScript are down right horrible. But they get the work done. In general dynamically typed scripting languages are playgrounds for errors - a statically typed paradigm might help - but we are too late for that.