How does your "terminal emulator program" communicate with this mainframe? The fact that it's a "mainframe" on the other end is no different than if it were a toaster oven; all you need to know is what communication protocol the emulator program uses, and then it's just a question of "Can PHP communicate via XYZ?"
For example, if the "XYZ" is "a serial COM port", then answer is, yes: both [man]fopen/man and the Direct IO functions (see: [man]dio[/man]) can open *nix devices such as "/dev/ttyS0" (and the Windows-equivalent "COM1:", too).