Wrapping encode fn in a class makes it work in PHP! Passes one simple test