“James while John had had had had had had had had had had had a better effect on the teacher” is an English sentence used to demonstrate lexical ambiguity and the necessity of punctuation, which serves as a substitute for the intonation, stress and pauses found in human speech.
The phrase can be understood more clearly by adding punctuation and quotation marks:
James, while John had had “had”, had had “had had”; “had had” had had a better effect on the teacher.
The meaning could thus be rendered “It was the case that while John used ‘had,’ James used ‘had had.’ The teacher preferred ‘had had.’”