php write function