totally converted into php

totally converted into php