general function for php