If the employer is allowing the employee to be relieved on 8th July, then the amount paid for the remaining days may be either counted as compensation for early relieving or the service period marked as leave. In the former case, the date of exit should be 8th July, and in the latter case, it will be 31st July. The employee should ensure which date the employer is going to mark as the exit date in PF records because nowadays there are overlapping dates due to negligence.
If the employee is joining another organization before 31st July, then he should get his date of exit (last working day) marked on 8th July. Conversely, if he is not joining another organization before 31st July, it is desirable to have it on 31st July. The only difference is that in the latter case, the amount the employer has paid for the period from 9th July till 31st July will be accounted as Salary, which will qualify for PF deduction and contribution, whereas in the former being a compensation not while on duty, no contribution becomes payable.